Execute Event
execEvent: function(el, type) { Event.observers.each(function(item,index) { if (item[0] == el && item[1] == type) { item[2](); throw $break; } }); }
TextSnippets > winton > event
2741 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Winton Welsh http://stu.dicio.us
execEvent: function(el, type) { Event.observers.each(function(item,index) { if (item[0] == el && item[1] == type) { item[2](); throw $break; } }); }
attachEvent: function(selector) { var sel = selector.split(':'); var el = this.el[sel[0]]; var ev = sel[1]; if (!el) return; if (!el.each) Event.observe(el, ev, this.events[selector]); else el.each( function(item, index) { Event.observe(item, ev, this.events[selector]); }.bind(this)); }, attachEvents: function() { for (property in this.events) this.attachEvent(property); }, removeEvent: function(selector) { var sel = selector.split(':'); var el = this.el[sel[0]]; var ev = sel[1]; if (!el) return; if (!el.each) Event.stopObserving(el, ev, this.events[selector]); else el.each(function(item, index) { Event.stopObserving(item, ev, this.events[selector]); }.bind(this)); }, removeEvents: function() { for (x in this.events) this.removeEvent(x); }