Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: add event when you open/close the niceselect #33

Closed
hiasl opened this issue Mar 16, 2022 · 1 comment
Closed

FR: add event when you open/close the niceselect #33

hiasl opened this issue Mar 16, 2022 · 1 comment

Comments

@hiasl
Copy link

hiasl commented Mar 16, 2022

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!

@Tsjippy
Copy link
Collaborator

Tsjippy commented Jan 14, 2023

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))

@Tsjippy Tsjippy closed this as completed Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants