Semantic-Org / Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.
http://www.semantic-ui.com
MIT License
51.07k stars 4.96k forks source link

Single dropdown on clear event #7104

Closed geekasso closed 1 year ago

geekasso commented 1 year ago

I have a searchable, clearable, single select drop-down, which makes an ajax call during onChange event.

When a user clears the selection using the clearable button, I need to get the values that were there without a separate button, preferably via the onChange event, so that the ajax function can run based on what occured.

Based on the documentation, it seems it may only be possible with a multi select drop down, not a single select. Is that the case? How could I implement this for a single select drop-down?

geekasso commented 1 year ago

Not sure if this is the cleanest way to get it done, but considering the documentation is quite hazy I ended up with this - which seems to work for my use case. I also have multiple drop downs on the page and this handles the data for the drop down where the values were cleared.

$('.dropdown.icon.clear').on('click', function (e) { e.preventDefault(); let value = $(this).prev().val(); if (value) { // do something } return; });