I need to bind event listener to all dynamicaly created elements by given css selector.
In jQuery, that would be
$(".foo").live("click", function(e) {
// bar
});
Is there any equivalent in Prototype for this?
I need to bind event listener to all dynamicaly created elements by given css selector.
In jQuery, that would be
$(".foo").live("click", function(e) {
// bar
});
Is there any equivalent in Prototype for this?
The correct answer to the question is here: http://gurde.com/2011/08/jquery-live-in-prototype/
The equivalent of the jQuery
.live()
in Prototype is the Event.on() method:Within the callback, the this keyword will always refer to the original element (in this case document).
This is usually done with
Event#findElement
: