YouTip LogoYouTip

Event Pagebeforeshow

jQuery Mobile pagebeforeshow Event | Tutorial

Tutorial -- Learning is not just about technology, but also about dreams!

jQuery Mobile Tutorial

jQuery Mobile Tutorial jQuery Mobile Introduction jQuery Mobile Installation jQuery Mobile Pages jQuery Mobile Transitions jQuery Mobile Buttons jQuery Mobile Button Icons jQuery Mobile Popups jQuery Mobile Toolbars jQuery Mobile Navigation Bars jQuery Mobile Panels jQuery Mobile Collapsibles jQuery Mobile Tables jQuery Mobile Grids

jQuery Mobile Lists

jQuery Mobile List Views jQuery Mobile List Content jQuery Mobile Filters

jQuery Mobile Forms

jQuery Mobile Form Basics jQuery Mobile Form Inputs jQuery Mobile Form Selects jQuery Mobile Form Sliders

jQuery Mobile Themes

jQuery Mobile Themes

jQuery Mobile Events

jQuery Mobile Events jQuery Mobile Touch Events jQuery Mobile Scroll Events jQuery Mobile Orientation Change Events jQuery Mobile Examples jQuery Mobile Data Attributes jQuery Mobile Icons jQuery Mobile Events jQuery Mobile Page Events jQuery Mobile CSS Classes jQuery Mobile Events jQuery Mobile Events jQuery Mobile Page Events

jQuery Mobile pagebeforeshow Event

jQuery Mobile Events jQuery Mobile Events

Example

Show an alert message before a page transition is displayed:

$(document).on("pagebeforeshow","#pagetwo",function(){
    alert("pagebeforeshow event triggered - Page Two is about to be shown");
});

Try it yourself Β»


Definition and Usage

The pagebeforeshow event is triggered before a page transition is displayed, after the transition has started.

Related Events:

  • pageshow - Triggered after a page transition is displayed.
  • pagebeforehide - Triggered before the old page is hidden during a page transition.
  • pagehide - Triggered after the old page is hidden during a page transition.

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


Syntax

To trigger the event for all pages in jQuery Mobile:

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

Try it yourself

To trigger the event for a specific page:

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

Try it yourself

Parameter Description
function(event,data) Required. Specifies the function to run 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, see the jQuery Event Reference.
  • data object - Contains the property prevPage, which returns the previous page of the transition.
_page_ Optional. The page id that the pagebeforeshow event points to. For internal pages, use #id. For external pages, use _externalfile.html_.

Example

More Examples

Demonstrate 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 triggered.

Data Object

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


jQuery Mobile Events jQuery Mobile Events jQuery Mobile Icons jQuery Mobile Page Events
← Event PagecreateEvent Pagebeforeload β†’