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.