YouTip LogoYouTip

Event Pagebeforecreate

# jQuery Mobile pagebeforecreate Event [![Image 4: jQuery Mobile Events](#) jQuery Mobile Events](#) ## Example Display some text when the page is initialized, before the enhancement begins: $(document).on("pagebeforecreate",function(){ alert("pagebeforecreate event triggered!") }); [Try it Β»](#) * * * ## Definition and Usage The pagebeforeload event is deprecated in jQuery 1.4.0. Use the (#) event instead. The pagebeforecreate event is triggered when a page is initialized and before jQuery Mobile starts enhancing the page. **Note:** This event can only be triggered once per page - when the page is first loaded, jQuery Mobile caches the page in the DOM (memory). So, when you navigate back to the first page from the second page using the browser, this event will not be triggered because the first page has already been initialized. **Related Events:** - Triggered after the page is created, before enhancement is complete. - Triggered after the page is initialized and enhancement is complete. * * * ## Syntax Trigger all page events in jQuery Mobile: $("document").on("pagebeforecreate",function(event){...}) (#) Trigger a specific page event: $("document").on("pagebeforecreate","_page_",function(event){...}) (#) | Parameter | Description | | --- | --- | | function(event) | Required. The function to execute after the pagebeforecreate event is triggered. The function is an optional event object containing any jQuery event properties (e.g., event.target, event.type, etc.). See the (#) for more jQuery event properties. | | _page_ | Optional. Used to specify the page ID for which the pagebeforecreate event is triggered. For internal pages, use _#id_. For external pages, use _externalfile.html_. | * * * ![Image 5: Examples](#) ## More Examples [Demonstration of pagebeforecreate, pagecreate, and pageinit.](#) This example demonstrates the triggering of the pagebeforecreate, pagecreate, and pageinit events. (#) Use the pagebeforecreate event to dynamically add attributes. (#) Use the event.type property to return the type of event triggered. * * jQuery Mobile Events](#)
← Event PagebeforehideEvent Orientationchange β†’