Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
12/07/12: Off with the Backbone!

Interestings

Backbone.off can unbind callbacks from all instances of a class instead of just the instance you want

If you set up some bindings such as

viewClass = Backbone.View.extend({...})
view1 = new viewClass();
view2 = new viewClass();
model.bind("event", view1.myFunction, view1)
model.bind("event", view2.myFunction, view2)

and then want to unbind one of the callbacks…

model.off("event", view1.myFunction)

you will unbind both callbacks. You need to use

model.off("event", view1.myFunction, view1)

This is fundamentally because of javascript prototypes that mean view1.myFunction == view2.myFunction

Comments
Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *