Open dw2 opened 8 years ago
Checked the log, which was going by too quickly to notice earlier. I get the error Uncaught Error: value not in set of provided options. I think this is because the number array is converted to strings when in the DOM. When the view reads these values later, it doesn't match the attribute, which is the number 2 instead of "2" as seen by the <option value="2">Twice</option>
HTML.
hey @dw2!
it's actually doing a ==
vs. a ===
, so i'm wondering if there's more than meets the eye. see here.
if you'd want to edit your node_modules/ampersand-select-view/ampersand-select-view.js and slap a debugger statement right around there, report back on this.options
and value
. these should be good clues to help us move along!
thx!
@cdaringe thanks for the reply. You are correct that it does a loose comparison with == for array options, but for textvalue option arrays, it uses indexOf to find the value. The PR I just made will apply a loose comparison in both cases, as well as allow for mixed option sets.
I'm attempting to use a select box to pick from an array of numbers with labels (i.e. [[1,'Once'], [2,'Twice'], ...]. However, since the attribute is set to 'number' in the model, this causes the form to fail. (Edit: more info below)