jQuery Mobile pagecreateEvents
Examples
When the page initializes, before enhancement is complete, pop up an alert:
alert("pagecreate event triggered!")
});
Try it Yourself »
Definition and Usage
The pagecreate event is triggered after the page is successfully created, but before jQuery Mobile completes the page enhancement.
Note:This event can only be triggered once per page. When the page is first loaded, jQuery Mobile caches the page in the DOM (memory). So when you return 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.
Note:Before version 1.4, we used the pageinit event (deprecated) to handle this.
Tip:This event is usually used when users want to enhance custom components on the page:
$(document).on("pagecreate","#pagetwo",function(event){
$.(":jqmData(role='my-plugin')").myPlugin();
});
Related events:
- pagebeforecreate- Triggered after the page is initialized, but before the page enhancement.
- pageinit- Triggered after the page is completely initialized and enhancement is complete.
Syntax
Trigger the event for all pages in jQuery Mobile:
Trigger the event for a specified page:
| Parameters | Description |
|---|---|
| function(event) | Required. Specifies the function to execute when the pagecreate event is triggered. The function has an optional event object, which can contain any jQuery event properties (event.target, event.type, etc. For more information, please refer to thejQuery Event Reference Manual 。 |
| page | Optional. Used to specify the page id where the pagebeforecreate event is triggered. For internal pages, use #id. For external pages, use externalfile.html. |

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