say I have some code like this:
Behaviour.register({
''#clickme'' : function(el) {
Event.observe(el, ''click'', function(event) {
alert("clickme was clicked");
});
}
});
Behaviour.apply();
Behaviour.apply();
the element with the id of ''clickme'' will now have 3 onclick
event observers.
Is there a way to work around this?
I see there''s Event.stopObserving, but I''m not sure how to use
it. I tried
this:
Behaviour.register({
''#clickme'' : function(el) {
var clickit = function(event) {
alert("clickme was clicked");
}
Event.unObserve(el, ''click'', clickit);
Event.observe(el, ''click'', clickit);
}
});
Behaviour.apply();
Behaviour.apply();
but it still seemed to add up the event handlers.
I have since rolled back to the old el.onclick = function() {} method, but
I''d
prefer to use Event.observe so I can easily apply multiple different event
handlers to an object, as well as having handy access to the event object (so
I''m not repeating code!) :)
Any help would be GREATLY appreciated :)
-Jeremy
--
Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org
In the beginning was The Word and The Word was Content-type: text/plain
-- The Word of Bob.
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs