[turboid] javascript solutions

Home     Contact     Search     About me
Syntax solutions
27 May 2012

Turboid Event Management

A short reference

Turboid offers a special object called "Event", which in turn offers very useful functions allowing you to manage your event handlers in a quite comfortable way.

This article is a reference which lists the functions belonging to the Turboid event management. Its functions are Event.add(), Event.set(), Event.drop(), Event.exists(), Event.guard(), and getTarget().

Event.add(handlerName, fnc [, extenderName])

Extends an event handler or a variable which contains a function with an additional function whithout replacing the first one. The argument 'handlerName' is a name like 'document.onclick', which must be passed as a string. The argument 'fnc' is the function which the handler is supposed to be extended with. It is no problem if the handler did not contain any function before, so 'fnc' can also be the very first function assigned to the handler. The argument 'extenderName' is optional, it is an arbitrary name you name your function with. You may need it to refer to the function later, for example to drop it by using Event.drop() out of the chain of functions which are extending the handler, or to replace within the chain by another function by using Event.set().

Cool feature: By using this way of declaring events the keyword 'this' does not point to the object which contains the handler property, but if you use the Turboid keyword that instead, you get the object. In order to get this to work, you have to 'mention' it in the function head of 'fnc'. Example:

Event.add("document.getElementById('field').onclick", function(that){
}, "myHandler");
Or in the shorter Turboid notation:
Event.add("id('field').onclick", function(that){
}, "myHandler");
And since the extender name is optional, there is an even shorter way:
Event.add("id('field').onclick", function(that){

Event.drop([handlerName, ] extenderName)

Deactivates a function which has been added to an event handler by Event.add(). If there has been no extender name defined in Event.add(), it would be necessary to pass instead of it a number, which indicates the index of the function in the chain of functions added to the handler.

Event.set([handlerName, ] fnc, extenderName)

Replaces one of the functions which extend a certain handler by another function (fnc). If the handler named in "handlerName" or the extender named in "extenderName" does not exist, the function behaves like Event.add().

Event.exists(handlerName, extenderName)

Returns whether a certain handler extension exists.


Observes an event handler to prevent it from being overwritten by another developer.


Returns the element which the event has been performed on by the user. Must be applied within the event handler function. If used with Event.add or Event.set, the function had must have an event parameter ("e"). Example:

Event.add("document.onmouseover", function(e){


Add comment:

Name: (required)
E-Mail: (required, remains invisible)
Please check all (anti-spam):