Choices triggers change event only if value of option is not empty

Created on 8 Nov 2017  路  7Comments  路  Source: Choices-js/Choices

I have dropdown where first option has empty value (in my domain model it means no choice). Choices does not trigger change event if user select this item, but empty value is value too. Is it bug or I missed something?

Most helpful comment

I have the same issue. Why the Choices doesn't work as a native dropdown in this case?
I have the following structure:

<select>
<option value="">Please Select</option>
<option value="1">Item1</option>
<option value="2">Item2</option>
</select>

The change event fires only if I chose any item, but does not fire if I chose the "Please select" option.

All 7 comments

I have the same issue. Why the Choices doesn't work as a native dropdown in this case?
I have the following structure:

<select>
<option value="">Please Select</option>
<option value="1">Item1</option>
<option value="2">Item2</option>
</select>

The change event fires only if I chose any item, but does not fire if I chose the "Please select" option.

Sorry closed this by accident. I think you鈥檙e right. I鈥檒l put a fix in for this with the next release.

I seem to have a related issue: Removing the last item - thereby leaving an empty list - does not invoke the change-handler, making it impossible to save an empty list.

As a workaround you can listen for the "choice" event instead of "change". This fires with each selection, regardless of the selected value.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Not solved yet?

@tekord This should now be fixed

Was this page helpful?
0 / 5 - 0 ratings