jQuery Mobile pageinitEvent
Examples
Pop up a message when the page initializes and enhances:
alert("pageinit \n event triggered!")
});
Try it Yourself »
Definition and Usage
This event has been deprecated since version 1.4.0, usepagecreateinstead.
The pageinit event is triggered after the page is initialized and after jQuery Mobile has finished enhancing the page content.
Use this event instead of the jQuery DOM ready event, because it can be triggered whether the page is directly loaded or called via Ajax.
Note:This event can only be triggered once per page - on the first load of the page, jQuery Mobile caches the page in the DOM (memory), so when you navigate back from a second page to the first page via the browser, this event will not be triggered because the first page has already been initialized.
Related events:
- pagebeforecreate- Triggered before page initialization and before jQuery Mobile starts enhancing the page.
- pagecreate- Triggered after the page is created, but before the page enhancement is complete.
Syntax
To trigger all page events in jQuery Mobile:
To trigger a specific page event:
| Parameters | Description |
|---|---|
| function(event) | Required. The function to be executed when the pageinit event is triggered. The function is an optional event object containing any jQuery event properties (e.g., event.target, event.type, etc.). SeejQuery Event Reference Manualfor more jQuery event properties. |
| page | Optional. Used to specify the page id for the pagebeforecreate event. For internal pages, use#id. For external pages, use externalfile.html。 |

More Examples
Demonstrations of the pagebeforecreate and pagecreate events.
This example demonstrates the triggering of the pagebeforecreate and pagecreate events.
Event Object
Use the event.type property to return the type of event triggered.
Other Extensions
jQuery Mobile Events