You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The default Backbone
delegateEvents()
includes a call toundelegateEvents()
so that all events on the view will be refreshed when it's called insiderender()
. However,delegateModalEvents()
does NOT include an equivalent call toundelegateModalEvents()
. This means that, if you re-render a Modal without first callingundelegateModalEvents()
, the default implementation ofrender()
will cause all of your events (including implicit Backbone.Modal events such assubmit
andcancel
!)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 callundelegateModalEvents()
before it does anything else.The text was updated successfully, but these errors were encountered: