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

Modals without duplicate event listeners #956

Merged

Conversation

skitterm
Copy link
Contributor

@skitterm skitterm commented May 7, 2018

This fixes the "duplicate modal listener" issue detailed in #954.

Similar to the pattern in dropdowns, check if the click event is already there before adding it to the modal toggles.

Note that toggleClick is moved outside the function modal. Otherwise, when calling modal() multiple times, duplicate events are getting bound. This is because the toggle click method is a different instance of the function each time modal() is called. Sticking it outside of the modal function ensures that it's the same instance of the function used by all modals (so the e.fn === toggleClick conditional is true when we'd expect).

I wasn't sure what to do with the else case (when node is passed to bindModals). I didn't see any usage of bindModals being called with node as an argument, but maybe that's in there for user customization? If it needs to remain there, it will need a similar "if the event exists, don't add it again" logic.

@macandcheese macandcheese merged commit 103dd67 into Esri:master May 8, 2018
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

Successfully merging this pull request may close these issues.

3 participants