Event delegation is just about hanging event handlers further up the DOM tree. All of the frameworks can/should be able to do that. The handlers should be able to pickup any event that bubbles. The event contains the element that triggered it, and from that the handler can do whatever.
Prototype doesn't have any event delegation sugar native to the library that works like jQuery's $.fn.live
, but it is fairly simple to build a function that catches events and does stuff with their target elements.
document.observe('click',function(event){alert(event.element().inspect())})
You can use this to make a clone of jQuery's live pretty easily(I am not saying this will perform well or anything).
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 could call it like:
live("div",function(){this.setStyle({color:'blue'})})
I guess what I am saying is that event delegation is built in to javascript already. Libraries just add sugar.