Hi,
I think it's pretty annoying to write
myelement.observe('click', function(event){
// do stuff
event.stop()
});
for every link etc for which you want to replace the click-
functionality. So I added a Method to Element that does the observer-
invoking and event-stopping for me and simply named it click. Like
with jQuery, the event only keeps bubbling if the given eventHandler
returns true.
Element.addMethods({
click: function(element, eventHandler) {
if (!(element = $(element))) return;
element.observe('click', function(event){
if(!eventHandler(event))
event.stop()
});
return element;
}
});
But I'm wondering. 'click' sounds like a name to me that could easily
cause conflicts. It works in Safari and FF though. Does anyone know if
there could be sideeffects or nameconflicts?
Thanks
Lukas
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.