Reputation: 520
I am trying to set a :default-value for a input select dropdown. If I hard-code a "2" it works. If I pass in a 2 that I read out of a PostgreSQL database it fails. I have tried (str ...) and (js/String ...) Nothing works. I have no idea how to "inspect" the type. I am passing these values to om-bootstrap.
tech-id (utils/techid job cursor)
(i/input
{:type "select"
:default-value tech-id }
(d/option {:value "1"} "one")
(d/option {:value "2"} "two")
(d/option {:value "3"} "three")
(d/option {:value "4"} "four") )
If I manually set tech-id to be "2" it displays "two". Using the value from the database, it displays "one". I can even set it to 2 and it works.
Upvotes: 1
Views: 1450
Reputation: 520
OK, so I think the first comment of (str 2) is correct and I was doing that. The problem is in the life-cycle of the "input" component. When I first create it, there isn't a value so it defaults to the first one in the list. Later I display it without redrawing it, so it has the original "default-value". I have to either find a way to "send" it a "select" message or re-draw it.
Upvotes: 1