I'm trying to rewrite a Mootools tooltip class in JQuery using this class plugin. When my class is instantiated I'm attaching an event listener to a target link which will fade out the tooltip.
In event callbacks JQuery assigns the keyword "this" to the target of the event, so to keep a reference to the properties of the class I'm using apply() to set "this" to mean the class instance. This is apparently the counterpart in JQuery of Mootools' handy bind() function.
Unfortunately when I use apply() I lose the callback's event parameter. For example, in this bit I get an "e is undefined" error on the second line.
this.target.bind('click', function(e){
e.preventDefault();
var tip = this.opts.tip;
tip.fadeOut(500, function(){
tip.bind('click', function(){
showing = false;
})
});
}.apply(this))
Am I missing a trick here? Does anybody know a way around this issue?