[jQuery] binding events and keep reference to the "this" object
I'm not sure if I've completely missed this in the docs, but I'm
wondering if there is an easier way of achieving the following:
$(".button").bind("click", {that:this}, function(event) {
var that = event.data.that;
that.handleEvent();
return false;
});
I could do the same thing in prototype using "bindAsEventListener"
like this:
Event.observe($$(".button"), 'click',
this.handleEvent.bindAsEventListener(this));
This would help tidy everything up a lot, since I'd like to maintain a
class-based pattern where "this" is used a lot. Passing it in as event
data seems like overkill.
Thanks :)