I have a problem with dropdowns in ractive with null values from json. It's best explained in the actual example in jsfiddle
Basically, list of workstations, when chosen, populates the rest of the form with values.
Problem is for example if you go on workstation 1 and then to workstation 3 which has department_id=null, and department dropdown does not reset to
<option value=''>
but stays on the one prior to change. Trying to set value of w to null before set to actual id does not help at all.
That's because null
and an empty string aren't the same. Ractive couldn't find a null
in <select>
. You can set value
to null
for the first option so that Ractive can find a null
in <select>
. http://jsfiddle.net/x5w5v2wy/10/
<option value='{{ null }}' selected>--Pick a Department--</option>
This is possible because Ractive allows a limited set of expressions inside {{ }}
, and luckily, null
is allowed.