The event system

The event system within JavaScript is an important part of the language. JavaScript was designed to respond to events in the browser and events caused by users. A website may need to respond to the click of a user, or an AJAX response from a server. With the language, you can attach functions called event handlers to listen for events from certain elements in the page and the browser.

In the Dojo framework, events are listened to using the dojo/on module. When assigning an event listener, the module function call returns an object that lets you discontinue listening by calling the object's remove() method. Also, dojo/on has a once() method that fires the event once, when the event occurs, then automatically removes the event.

Get Mastering ArcGIS Server Development with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.