documentcloud/backbone — pull request #729 by krange (2011-11-08 13:05:29+00:00)
Title: Inclusion of a context parameter to unbind method

Update to unbind method to allow a context parameter. This fixes an issue where bindings aren't removed correctly where 2 instances of the same class listening to the a single instances' trigger event. When unbinding from the second instance, unbind method actually unbinds the first registered instance. Example of the error below:

```
var DispatchModel = Backbone.Model.extend({
});

var RespondModel = Backbone.Model.extend({
defaults: {
dispatchModel: undefined
},

initialize: function () {
var dispatchModel = this.get('dispatchModel');
dispatchModel.bind('change', this._onDispatchChange, this);
},

dispose: function () {
var dispatchModel = this.get('dispatchModel');
dispatchModel.unbind('change', this._onDispatchChange);
},

_onDispatchChange: function () {
}
});

var respond1Model, respond2Model, dispatchModel;
dispatchModel = new DispatchModel();
respond1Model = new RespondModel({dispatchModel: dispatchModel});
respond2Model = new RespondModel({dispatchModel: dispatchModel});

respond2Model.dispose();
console.log(dispatchModel._callbacks);
```