Techwraith/ribcage-view — pull request #16 by ben-ng (2014-01-11 01:32:52+00:00)
Title: Add bindEvents

This calls `bindEvents` before `loadData` on every render. It makes dealing with `Backbone.sync` much cleaner.

Use case:

```js
myView = Ribcage.extend({
afterInit: function () {
this.model = new MyModel()
}
, bindEvents: function () {
this.listenTo(this.model, 'change', this.render, this);
}
, loadData: function (cb) {
this.model.once('sync', cb);
this.model.fetch();
}
});
```

Notes:
* I didn't call it `beforeLoadData` because it has to run on every render, not just renders that load data.
* I couldn't bind my events in `afterRender` because it doesn't get called if data isn't loaded yet. So the model would sync, but the event wouldn't be bound and the view wouldn't update
* This is really useful in subviews because if the parent view is rendered the events don't disappear