I wasn't sure of the title, but I hope you will be able to help me.
I want to use kinda the same pattern that jQuery uses for their event handlers, like click/hover/blur etc, where you use this inside the event handler to get the object.
How do I accomplish this?
// The event handler
var handler = function() {
alert(this); // how do I set "this" in the trigger?
}
// The function that triggers the event handler
var trigger = function(handler) {
var o = someObject;
if($.isFunction(handler)) handler(); // how do I set "o" as the this-reference in handler?
}