jashkenas/backbone — pull request #3193 by Robovirtuoso (2014-06-16 19:20:05+00:00)
Title: Extend Backbone.View#delegate to listen to models

A lot of times Backbone views will have the responsibility of listening and responding to events happening on it's model. This yields code that looks like the following:

```js
var ExampleView = Backbone.View.extend({
events: {
'click': 'handleClick'
},
initialize: function() {
this.listenTo(this.model, 'change', this.render);
},
render: function() {};
});
```

Backbone views currently provide a convenience syntax for listening to events on it's element. This commit extends that functionality to give you convenience syntax for the model.

```js
var ExampleView = Backbone.View.extend({
events: {
'click': 'handleClick',
'@model change': 'render'
},
render: function() {
console.log('triggered because of the model!');
};
});

var model = new Backbone.Model()
new ExampleView(model: model);

model.trigger('change');
//=> 'triggered because of the model!'
```