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

delegateModalEvents() doesn't undelegate events first #105

Open
kevinhb opened this issue Dec 18, 2018 · 0 comments
Open

delegateModalEvents() doesn't undelegate events first #105

kevinhb opened this issue Dec 18, 2018 · 0 comments

Comments

@kevinhb
Copy link

kevinhb commented Dec 18, 2018

The default Backbone delegateEvents() includes a call to undelegateEvents() so that all events on the view will be refreshed when it's called inside render(). However, delegateModalEvents() does NOT include an equivalent call to undelegateModalEvents(). This means that, if you re-render a Modal without first calling undelegateModalEvents(), the default implementation of render() will cause all of your events (including implicit Backbone.Modal events such as submit and cancel!)
to be bound AGAIN, which results in all submit/cancel callbacks firing multiple times for a single button click.

I can't imagine a single sane reason why you would want to delegate events in this function without undelegating first (hence the Backbone behavior, duh) and the current behavior requires making an extra function call before every call to render() if you want to avoid bugs that, if this were vanilla Backbone, would seem completely inexplicable. delegateModalEvents() should call undelegateModalEvents() before it does anything else.

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

1 participant