jQuery Mobile pageshowEvent

jQuery Mobile 事件jQuery Mobile Events

Examples

Pop up a message after the page is displayed following a page transition:

$(document).on("pageshow","#pagetwo",function(){
alert("pageshow event triggered - displaying page two");
});

Try it Yourself »

Definition and Usage

The pageshow event is triggered after the page is displayed following a page transition.

Related events:

  • pagebeforeshowThe event triggered before the page is displayed after a page transition.
  • pagebeforehideThe event triggered before the old page is hidden after a page transition.
  • pagehideThe event triggered after the old page is hidden after a page transition.

Note:This event is triggered when the page transition starts/ends.


Syntax

Trigger all page events in jQuery Mobile:

$("document").on("pageshow",function(event){...}) Try it Yourself

Trigger a specific page event:

$("document").on("pageshow","page",function(event,data){...}) Try it Yourself

Parameters Description
function(event,data) Required. Specifies the function to execute when the pageshow event is triggered.

This function contains the following two parameters:

  • Event object- Includes any jQuery event properties (event.target, event.type, etc.). For more information, seejQuery Events Reference Manual
  • Data object- Contains the property nextPage, the transition page to return to.
page Optional. Specifies the page id that the pagebeforehide event points to when triggered. For internal pages, use#id. For external pages, use externalfile.html。


实例

More Examples

Related event demonstration.
This example demonstrates the triggering of the pagebeforeshow, pageshow, pagebeforehide, and pagehide events.

Event object
Use the event.type property to return the type of event triggered.

Data object
Use the prevPage property to return the previous page.


jQuery Mobile 事件jQuery Mobile Events

Other Extensions