Index | OAT homepage | OpenLink Software

# OATDOCevents

- OATDOCevents
- _ _ Event handling basics
- _ _ _ _ OAT.Event.attach(element, event, functionReference)
- _ _ _ _ _ _ Examples
- _ _ _ _ OAT.Event.detach(element, event, functionReference)
- _ _ _ _ _ _ Example

## Event handling basics

Event handling is very simple in this toolkit. There are two routines that accomplish this:

### OAT.Event.attach(element, event, functionReference)

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., the name of an existing function or Anonymous function.

#### Examples

    var div = OAT.Dom.create("div");
    OAT.Event.attach(div, "mouseover", function() { alert('Hi!'); });

or

    OAT.Event.attach("some_id", "click", genericFunctionReference);

### OAT.Event.detach(element, event, functionReference)

Use the same syntax as in `OAT.Event.attach()` .: The `functionReference` argument must exist in the current scope, so it is not possible to remove an `event` handled by anonymous function.

#### Example

    OAT.Event.detach(element, "click", functionReference);

Copyright (C) 2005-2008 OpenLink Software