Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile pagebeforeshow Event

jQuery Mobile pagebeforeshow Event

jQuery Mobile Events jQuery Mobile Events

Example

Text pops up after a page transition and before display:

$(document).on("pagebeforeshow","#pagetwo",function(){

  alert("pagebeforeshow event triggered - page two is about to be shown");

});

Try it »


Definition and Usage

pagebeforeshow is an event triggered after a page transition and before display.

Related events:

Note: This event is triggered at the start/stop of each transitioning page.


Syntax

To trigger the event for all pages in jQuery Mobile:

$("document").on("pagebeforeshow",function(event){...})

Try it

Trigger an event for a specified page:

$("document").on("pagebeforeshow","

page

",function(event,data){...})

Try it

Parameters Description
function(event,data) Required. Specifies the function to execute when the pagebeforeshow 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, refer to the jQuery event reference manual
  • Data object - Contains the prevPage property, which returns the previous page of the transition.
  • | | *page* | Optional. The id of the page the pagebeforeshow event points to. For internal pages, use #id. For external pages, use * externalfile.html*. |

    More examples

    Demo related events
    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 that was triggered.

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


    jQuery Mobile Events jQuery Mobile Events