O'Reilly logo

PhoneGap Essentials: Building Cross-Platform Mobile Apps by John M. Wargo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17. Events

The PhoneGap Events API provides an application with the ability to register event listeners for different events that occur on a supported smartphone device. The following is a list of the types of events supported by PhoneGap:

deviceready event

• Application status events

• Network events

• Button events

The subsequent sections in this chapter will describe each of these event types in detail.

Creating an Event Listener

To create an event listener in a PhoneGap application, execute the following code:

document.addEventListener("eventName", functionName,  useCapture);

The parameters passed to addEventListener are as follows:

eventName: String value specifying the name of the event the listener will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required