When you try to access this.remove inside the anonymous function, "this" is
no longer bound to the class. Try binding that function,  or keeping a
reference to "this" before the anonymous function.

Sean McArthur
On Nov 28, 2010 9:22 AM, "Dailce" <[email protected]> wrote:
> Hi, I really like this notification class, and I've been trying to
> port it over to mootools 1.3 (no compatibility).
>
> here is the link: http://jsfiddle.net/PCn4W/1/
> Credit goes to Harald Kirschne
>
> However, I seem to be getting an error in the following block of code:
>
> this.items.push(item.addEvent('click', remove));
> if (this.options.duration) {
> var over = false;
> var trigger = (function() {
> trigger = null;
> if (!over) remove();
> }).delay(this.options.duration);
> item.addEvents({
> mouseover: function() {
> over = true;
> },
> mouseout: function() {
> over = false;
> if (!trigger) remove();
> }
> });
> }
>
> If I change this.items.push(item.addEvent('click', remove));
> TO: this.items.push(item.addEvent('click', function()
> {this.remove()}));
>
> Then the notifications fire, however, the trigger function doesn't
> work.
> Firebug says something like remove is not a function.
>
> What am I missing?
>

Reply via email to