Skip to content

Instantly share code, notes, and snippets.

@potench
Created May 5, 2011 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potench/958127 to your computer and use it in GitHub Desktop.
Save potench/958127 to your computer and use it in GitHub Desktop.
var Ex = Ex || {};
Ex.A = RED.Class.extend({
init : function() {
this.resize = this.delegate(this, this.resize); // encapsulates to keep scope
$(window).bind('resize', this.resize);
$("body").bind('click', this.delegate(this,function() {
console.log('clicked');
$(window).unbind('resize', this.resize);
}));
},
resize : function(e) {
console.log(e); // event, event.target for DOM access
console.log(this); // ESPN.Page() instance
}
});
var t = new Ex.A();
// click the body to detach the listener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment