bluzky/nice-select2

FR: add event when you open/close the niceselect

hiasl opened this issue · 1 comments

hiasl commented

Hi,
We are using both single and multiselects and I want to submit a form when something changes. For single selects this can easily be done by listening to the change event of the original select, but for multiselects this would be triggered on the first change, but instead I want to react once the pulldown is closed. I should actually monitor if something has changed while the nice-select is opened and trigger the submission once the niceselect is closed.

Could you please add an event when the nice select opens and another event when it gets closed.

And if you want to be super handy you could fire an event for both single and multiselects if something has changed on close. That would, for example, prevent event triggering when the same option is selected and unselected again in a multiselect and closed.

Thanks!

You can now do this: document.querySelector("#someSelect").addEventListener("modalclose", ev=>console.log(ev.target))
document.querySelector("#someSelect").addEventListener("modalopen", ev=>console.log(ev.target))