attaches the handler to an inner event of the component
type | string | the event name, case-insensitive |
functor | function | the function object or name |
id | string | optional, the event id |
id | the id of the attached event handler |
dtable.attachEvent("onAfterLoad",function(){
this.select(2);
});
You can use the method with an inline function or provide just the global function reference. In the second case, be sure that the function is visible from the calling point.
function doTask(){ ... };
dtable.attachEvent("onBeforeLoad", doTask); // uses the reference
The last parameter allows you to define the id of the attached handler. If it was not specified, some unique value will be assigned as the id. The only purpose of such id - detaching the handler from an event (in most cases you don't need to care about the handler id).
Check the related documentation to get the full list of parameters. The amount and meaning will vary for different events.
The value which is returned by an event can change behavior of component. Returning true or nothing will be considered as the positive signal, while returning false will be considered as a signal to stop the current activity.
dtable.attachEvent("onBeforeSelect", function(id){
if (id == 123)
return false; // blocks selection of a specific element
});