Event handling is very simple in this toolkit. There are two routines that accomplish this:
You should supply exactly three arguments to this routine. For instance,
var div = Dom.create("div");
Dom.attach(div, "mouseover", function() { alert('Hi!'); });
or
Dom.attach("some_id", "click", genericFunctionReference);
First argument specifies an element which should detect the event. Second is the event (without the 'on' prefix). Last argument is a valid function reference, i.e. a name of existing function or Anonymous function.
We use the same syntax as in Dom.attach()
:
Dom.detach(element, "click", functionReference);
The functionReference
argument must exist in the current scope, so it is not possible to remove an event handled
by anonymous function.