[jQuery] Using existing functions for event handlers
Hi,
When calling, say, $('a').click(...), I'm trying to pass a pre
existing function in - my attempts so far:
$('a').click(function(e){return handlerObj.handleEvent(e)});
No surprise to anyone that i run into scoping issues, with 'this'
referring to the handlerObj rather than the dom element, as it would
do in the function passed as the click's param.
I used Firebug to take a peek at the event object, to try and see if
JQ provided a (cross browser!) reference to the dom element.
I found various possibilities: currentTarget, originalTarget, target,
etc, but I want to know what's best practice for this in JQ - or
perhaps my whole approach should be modified?
Thanks!