NYTimes/backbone.stickit — pull request #98 by underbluewaters (2013-05-02 16:26:31+00:00)
Title: Add view reference to stickitChange events

It can be useful when handling stickitChange events to know which view handled that change in cases where two or more views are monitoring the same model.

In my case, I was trying to bind multiple Chosen widgets to a single model attribute and using the [example](https://github.com/NYTimes/backbone.stickit/issues/73#issuecomment-17052649) provided in issue #73 to call `liszt:updated` when a value changed. A simple check of o.stickitChange didn't work in this case. I've modified the example below to work with the new stickitChange.view reference.

```javascript
Backbone.Stickit.addHandler({
selector: 'select.chosen',
initialize: function($el, model, opt) {
var e, up, view,
_this = this;
e = "change:" + opt.observe;
$el.chosen({
disable_search_threshold: 7
});
view = this;
up = function(m, v, o) {
if (!(o.stickitChange && o.stickitChange.view === view)) {
return $el.trigger("liszt:updated");
}
};
this.listenTo(model, e, up);
return this.listenTo(model, 'stickit:unstuck', function() {
return _this.stopListening(model, e, up);
});
}
});
```