Event binding in MooTools like jQuery -


is there way assign multiple event types in mootools jquery?

mootools: $$('#id').addevents({     keyup: fn,     click: fn });  jquery: $('#id).bind('keyup click' ,fn); 

yes, there way, through powerful implement:

element.implement({     fakebind : function(evtsstr, callback){         var events = evtsstr.split(' '),              = 0,              l = events.length;         (; < l; i++){             this.addevent(events[i], callback);         }     } });  $$('div.myclass').fakebind('click mouseleave', function(event){     console.log(event.type); }); 

demo


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -