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 be listening for

functionName ...

Get PhoneGap Essentials: Building Cross-Platform Mobile Apps now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.