documentcloud/backbone — pull request #1468 by spacenick (2012-07-03 12:53:49+00:00)
Title: Add custom "fetch" events on Models and Collections

...found this pretty useful to add "generic" loader views on any collections/models.

Simple example, a generic loader that can be quickly binded to any collection, and will do the job.

```javascript
var Loader = Backbone.View.extend({

tagName:'img',
attributes:{
src:'loader.gif'
},

initialize:function() {
_.bindAll(this,'hide','show')
this.collection.on('reset',this.hide);
this.collection.on('fetch',this.show);
},

hide:function() {
$(this.el).hide();
},
show:function() {
$(this.el).show();
}

})
```