jQuery Mobile pagebeforecreate Event
Example
Some text pops up when the page is initialized, before enhancement begins:
$(document).on("pagebeforecreate",function(){
alert("pagebeforecreate event triggered!")
});
Try it »
Definition and Usage
The pagebeforeload event was deprecated in jQuery 1.4.0. You can use the pagecontainerbeforeload event instead.
The pagebeforecreate event is triggered when the page is initialized and before jQuery Mobile begins enhancing the page.
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 navigate back from a second page to the first page through the browser, this event will not be triggered, because the first page has already been initialized.
Related events:
- pagecreate - Triggered after the page is created and before enhancement is complete.
- pageinit - Triggered after the page is initialized and when enhancement is complete.
Syntax
Trigger all page events in jQuery Mobile:
$("document").on("pagebeforecreate",function(event){...})
Try it
Trigger a specified page event:
$("document").on("pagebeforecreate","
page
",function(event){...})
Try it
| Parameters | Description |
|---|---|
| function(event) | Required. The function specified to execute after the pagebeforecreate event is triggered |
函数是一个包含任何Jquery事件属性的可选事件对象 (例如 event.target, event.type, 等)。参阅 [jQuery 事件参考手册](/jquery/jquery-ref-events.html) 查看更多jQuery事件属性。 |
| page | Optional. Used to specify the page id on which the pagebeforecreate event is triggered. For internal pages, please use #id. For external pages, use * externalfile.html*. |
More examples
Demonstration of pagebeforecreate, pagecreate, and pageinit.
This example demonstrates the triggering of the pagebeforecreate, pagecreate, and pageinit events.
Modifying content
Use the pagebeforecreate event to dynamically add attributes.
Event Object
Use the event.type property to return the type of event that was triggered.
jQuery Mobile Events