Oracle CRM On Demand JavaScript API Developer's Guide > JavaScript API Reference > Methods for the Button Object >

Defining an Event Handler for a Button


To define an event handler for a button, you must define a JavaScript function in the following format:

function YourFunName(evt,data){

this.xxxxx();

}

The evt parameter is the regular event object from the browser. The data parameter is the additional data that you want to pass to the event handler. Both of these parameters are optional.

Inside the function body, the this keyword points to the current Button object to which this event handler is attached.

You can attach the event handler to your button using this code:

btn.on("click",YourFunName,"Your String");

In this example, "Your String" is passed as the data parameter to the event handler function YourFunName() when the button is clicked.

Oracle CRM On Demand JavaScript API Developer's Guide, Release 38 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Legal Notices.