jQuery Mobile pagebeforeshow Event | Tutorial
Tutorial -- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
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 GridsjQuery Mobile Lists
jQuery Mobile List Views jQuery Mobile List Content jQuery Mobile FiltersjQuery Mobile Forms
jQuery Mobile Form Basics jQuery Mobile Form Inputs jQuery Mobile Form Selects jQuery Mobile Form SlidersjQuery Mobile Themes
jQuery Mobile ThemesjQuery 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 ClassesjQuery Mobile pagebeforeshow Event
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");
});
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){...})
To trigger the event for a specific page:
$("document").on("pagebeforeshow","_page_",function(event,data){...})
| Parameter | Description |
|---|---|
| function(event,data) | Required. Specifies the function to run when the pagebeforeshow event is triggered. This function contains the following two parameters:
|
| _page_ | Optional. The page id that the pagebeforeshow event points to. For internal pages, use #id. For external pages, use _externalfile.html_. |
More Examples
This example demonstrates the triggering of the pagebeforeshow, pageshow, pagebeforehide, and pagehide events.
Use the event.type property to return the type of event triggered.
Use the prevPage property to return the previous page of the transition.
YouTip