How can I access a delegated object inside a delegate event handler? Hopefully an example should clarify my vague question.
$parent.delegate('a.some_class', 'click', someHandler);
function someHandler(e) {
//how do I find $parent here?
}
This is partly down to how I’ve structured my particular .js file, where declarations are separate from implementation (yeah, old skool I know).
In someHandler, e.target and $(this) refer to the a.some_class object. Does e also have a reference to $parent? If not, what is the recommended way of finding the $parent?
Thanks for any help.
UPDATE: There is a way to grab the original element –
e.originalEvent.currentTarget:DEMO: http://jsfiddle.net/pjHQ6/
Original answer:
I’d probably do it like this: