FREE Web Template Download
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULARJS TUTORIALS REFERENCES EXAMPLES Blog
 

jQuery pagecontainerbeforeload Event

jQuery Mobile Events jQuery Mobile Events

Example

Alert some text before a load request is made:

$(document).on("pagecontainerbeforeload",function(){
  alert("pagecontainerbeforeload event fired!");
});
Try it Yourself »

Definition and Usage

The pagecontainerbeforeload event is triggered before any load request is made.

Related events:

Note: These events are used for external pages - Whenever an external page is loaded into the DOM, 2 events are fired. The first is pagecontainerbeforeload. The 2nd event will either be pagecontainerload or pagecontainerloadfailed.


Syntax

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

Parameter Description
function(event,data) Required. Specifies the function to run when the pagecontainerbeforeload event occurs.

The function has two optional parameters:

The event object - which can contain any jQuery event properties (e.g. event.target, event.type, etc.) See jQuery Events Reference for more information

The data object - contains the following:

  • url (string) - contains the absolute or relative URL of the page (that was sent to $.mobile.loadPage())
  • absUrl (string) - contains the absolute reference of the URL
  • dataUrl (string) - contains the URL of the browser's location
  • deferred (object) - contains resolve() or reject()
  • options (object) - contains the options that were sent to $.mobile.loadPage()
Note: You can manually handle the load request by calling the event.preventDefault() on the event object and resolve() or reject() on the deferred object contained in the data object.

Examples

Try it Yourself - Examples

A demonstration of related events
A demonstration of pagecontainerload and pagecontainerloadfailed.

The event object
Using the event.type property to return the triggered event type.

The data object
Using the data.url to return the URL of the external page.


jQuery Mobile Events jQuery Mobile Events