ff0000/rosy — pull request #58 by doctyper (2012-08-29 18:27:52+00:00)
Title: Auto jQuery event unbinding

This pull request introduces automatic jQuery event unbinding on `.destroy()`. Provided you follow a couple of ground rules, it will just work.

- Methods bound to events must be attached to the Class. For example, this will not work with anonymous functions.
- Elements bound to events must be attached to the Class. Again, this won't work for local references.

A quick example:

```
var Test = View.extend({
dom : {},
vars : {},

init : function () {

// Attach to class
this.vars.body = $("body");

// Also this
this.dom.body = $("body");

// Or even this (ew...)
this.$body = $("body");

this.setupEvents();
},

setupEvents : function () {

// This method will be unbound on destroy
this.vars.body.on("click", this.onClick);

// This too
this.vars.body.on("click", "div", this.onClick);

// It can be proxied as well. It will still work
this.vars.body.on("click", "div", this.proxy(this.onClick));

// This method will not be unbound. You'll need to take care of it in .destroy()
this.vars.body.on("click", "div", function (e) {
console.log(e);
});
},

onClick : function (e) {
console.log(e);
},

destroy : function () {

// Calls the super, DOMManager does the rest.
this.sup();
}
});
```