Latest web development tutorials

jQuery Mobile pageinit event

jQuery Mobile Events jQuery Mobile Events

Examples

Pop-up message when the page initialization and enhancements:

$(document).on("pageinit",function(){
alert("pageinit 事件触发!")
});

try it"

Definition and Usage

The event was abandoned after version 1.4.0, use pagecreate instead.

After pageinit trigger event after page initialization and jQuery Mobile has completed the page content increased.

Use this event to replace the jQuery DOM ready event, because whether the page is loaded directly or through Ajax calls can be triggered.

Note: This event can only be triggered once per page - when the page is first loaded, jQuery Mobile in the DOM (memory) cache pages, so when your browser fallback from the first second page when the page, the event will not be triggered because the first page has been initialized.

Related events:

  • pagebeforecreate - at page initialization and jQuery Mobile enhanced page before starting the trigger.
  • pagecreate - after the page is created results, but the page before the completion of the enhanced trigger event.

grammar

Trigger events in all pages in jQuery Mobile:

$("document").on("pageinit",function(event){...}) 尝试一下

Trigger the specified event page:

$("document").on("pageinit"," page ",function(event){...}) 尝试一下

parameter description
function (event) have to. After pageinit letter specified trigger event execution

Any optional function is a jQuery event object event properties (such as event.target, event.type, etc.) contain. See jQuery Events Reference Manual for more jQuery event properties.
page Optional. It is used to specify an event triggered pagebeforecreate page id. Inside page, please use #id. External page, use externalfile.html.


Examples

More examples

pagebeforecreate, presentation pagecreate event.
This example shows pagebeforecreate, pagecreate trigger event.

Event objects
Use event.type property to return the type of trigger event.


jQuery Mobile Events jQuery Mobile Events