O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Removing a chain of events

Extending upon the chain of events created in the previous section, this recipe shows us how to clear a chain of events using Chain.clearChain().

Getting ready

Get ready to call this function by adding a widget to which our clearing function can be bound.

<input type="button" id="mycancel" value="Clear Chain"/>

How to do it...

Calling the clearChain() method of the my_chain object, which is an instantiation of MooTools Chain, removes the current call stack completely.

$('mycancel').addEvent('click',function() {
alert('Clearing chain:'+my_chain.$chain.length+' actions');
my_chain.clearChain();
alert('Done! Chain has:'+my_chain.$chain.length+' actions');
});

How it works...

Each call to my_chain.chain(advance_one_number)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required