Latest release: v0.5.2WebApp.Net documentation

Working with events

This page is specific to: WebApp.Net Version:0.20.30.50.6

December, 24th 2009

WebApp.Net provides some new events to let you to catch common framework activities such as: framework loaded and ready to go, start and end of sliding effect, device orientation change, ajax processing and so on. WebApp.Net framework provides two methods for this purpose. The list of available events is presented below.

The AddEventListener method


This method let you register an new event handler. You can add more than a single handler for an event with mutilple call to this method. An anonymous function can be used as handler but you will not be able to remove this listener later.

js
WebApp.AddEventListener(eventName, handler);

Register an event listener.

eventName
Madatory (String). The name of the event to listen to, from the following list:
handler
Madatory (Function). The function to call when the event is raised. The handler will received an event object containing contextual information.
It has the following signature: MyFunction(evtObj).

The RemoveEventListener method


This method let you unregister an previously set event handler. You can remove more than a single handler for an event with mutilple call to this method.

js
WebApp.RemoveEventListener(eventName, previousHandler);

Unregister a previously set event listener.

eventName
Madatory (String). The name of the event to listen to. The list is the same as The AddEventListener method.
previousHandler
Madatory (Function). The function to call when the event is raised. The handler will received an event object containing contextual information.
It has the following signature: MyFunction(evtObj).

Common event object structure


All events have a common structure as shown below:

object

The event object has the following properties.

type
(String). Name of the actual event.
target
(Object). Object which fires the event. Not defined in most cases.
context
(Object). The context data of the event. Read the event detail for more information about its content.
windowWidth
(Number). Current client window width.
windowHeight
(Number). Current client window height.

History


Date Version By Changes
20090307 0.5.0RC3 CA

Removed error, success (use endasync instead)

Added beginasync, willasync, endasync events

20080609 0.3.5m CA

Added error, success and tabchange events

Added target property

WebApp.Net