I’ve recently been using Prototype 1.6 and had a need for a jQuery.live() clone. The following code appears to emulate mouse events well (form submits [and maybe more…] do not work in IE):
Event.live = function(s, e, f) {
Event.observe(document, e, function(event) {
if (Element.match(event.target, s)) {
if (!(f.call(event.target, event))) {
event.stop();
}
}
});
}
To use this run something like the following:
Event.live('div#doesnt_exist_yet a.button', 'click', function() {
// run this when the button is clicked
});
Hope this helps!