addWebEventMapping

addWebEventMapping(eventName:      String;
                   scriptFunction: String): Boolean;

The addWebEventMapping method of the Window class adds a function to be invoked when the event specified in the eventName parameter occurs.

Use the scriptFunction parameter to specify the function that is to be invoked. For example, the following code fragment processes a lostFocus event on a TextBox control on the client Web browser.

textbox.addWebEventMapping("onLostFocus", "processLostFocus(this, 'lostFocus')");

The code fragment in the above example generates the following HTML fragment, which has been simplified for clarity.

<input type=text name=textbox onLostFocus="processLostFocus(this, 'lostFocus');">

In the HTML fragment shown in the above example, the processLostFocus script function is called when the text box loses focus. It is your responsibility to write this function and include this as part of the userScript property when you dynamically specify it in your code. As your function is not validated, it is your responsibility to ensure that it works as intended.

This method returns false if the function name is the same as the name that JADE generates automatically, and the mapping is not added to the control.

In general, do not use functions that begin with _ jade.

The code fragment in the following example displays an alert message box but does not submit the form.

btnOK.addWebEventMapping("onClick", "alert('enter value'); return false;");