What JavaScript libraries have event delegation?

I want to try the new JavaScript library. Using (and loved) j Query 1.3 "Live" events , I would prefer the following library in which I am trying to enable the event delegation event system. A comparison of the Wikipedia JS Library falls here.

Looks like MooTools gets it in version 2.0 . What about others?

I create this community wiki. Please help me fill out the list.

Prototype: no

jQuery: since 1.3

MooTools: from 2.0

ExtJS: yes

+5
source share
5 answers

Event delegation is easier than you think.

, .

+2

Prototype. SO , jQuery, JS- .

, , .

+2

JQuery, , - , mootools, Aarons , , , . , - , .

Mootools , , mootools dev JQuery. . http://davidwalsh.name

+1

- DOM. / . , . , , .

, , jQuery $.fn.live, , .

document.observe('click',function(event){alert(event.element().inspect())})

You can use this to make the jQuery live clown pretty easy (I'm not saying this will work well or something else).

live = function(selector,callback){
  document.observe("click",function(e){
    var element = e.element()
    if (!element.match(selector))
      element = element.ancestors().find(function(elem){return elem.match(selector)});
    else
      element = null
    if (element)
      callback.apply(element)
  })
}

You can call it like this:

live("div",function(){this.setStyle({color:'blue'})})

I assume that I say that event delegation is already built into javascript. Libraries just add sugar.

+1
source

Ext Js always guess.

+1
source

All Articles