pp108 : addListener()

addListener()


It registers the control to receive notifications for an event. This method binds the specified function to the event such that the function is called whenever the event is fired on the control.

Syntax

Script <control ID>.addListener(sEventName, fpFunction)


Possible Values

sEventName Required. String that denotes any of the standard XForm events.
fpFunction Required. Pointer that specifies the function to be invoked when the event is triggered.


Return Value


No value is returned.

Remarks

Using the addListener() method, you can attach multiple event handlers to an event. The order of execution of events is as follows:

  1. Events registered through the property sheet of the control or model in design time.
  2. Successive invocations of the addListener() method, in order.

    For methods attached to an event using the addListener method, use the removeListener() method to detach them, and prevent the execution of the function when the event is fired.

    The addListener() method supports the following events.

Model Events
xforms-onbeforeinsert, xforms-insert, xforms-onafterinsert, xforms-onbeforedelete, xforms-delete, xforms-onafterdelete, xforms-onbeforechange, xforms-change, xforms-onafterchange, xforms-onbeforesynchronize, xforms-onsynchronized, xforms-onrequest, xforms-onresponse, xforms_onfind, xforms-onsoapfault, xforms-ondatacompleted.

HTML Control Events
xforms-onbeforezoom, xforms-onafterzoom, xforms-onexpand, xforms-oncollapse, xforms-before-data-bind, xforms-onvalidate, xforms-value-changed, DOMFocusIn, DOMFocusOut, xforms-select-before-data-fill, xforms_onrowselect, xforms_onrowchecked, onbeforesynchronizeddialogopen, xforms-activate, onbeforeinsert, onbeforedelete, onbeforerefresh, onbeforefirst, onbeforenext, onbeforeprevious, onbeforelast, onbeforefind, onbeforeshowall, onbeforesave, onafterinsert, onafterdelete, onafterrefresh, onafterfirst, onafternext, onafterprevious, onafterlast, onafterfind, onaftershowall, onaftersave.

Example


This example demonstrates the use of the addListener() method to attach thecallOnBeforeZoomfunction with the Before Zoom event of a control.

// input1 is the ID of the control to which zoom is attached input1.addListener("xforms-onbeforezoom", callOnBeforeZoom);  // implementation for the function function callOnBeforeZoom(eventObject) {      // eventObject can be used to access event's properties 	    alert(cordys.getXML(eventObject.applicationDefinition)); }

Applies to


All Controls, Model, Webform

Related reference

removeListener()