July 2011
Intermediate to advanced
276 pages
5h 11m
English
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().
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"/>
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');
});
Each call to my_chain.chain(advance_one_number)