diff --git a/docs/api/events.html b/docs/api/events.html index 77b5b0e1..23df5cf1 100755 --- a/docs/api/events.html +++ b/docs/api/events.html @@ -25,6 +25,10 @@
jQuery Mobile offers several custom events that build upon native events to create useful hooks for development. Note that these events employ various touch, mouse, and window events, depending on event existence, so you can bind to them for use in both handheld and desktop environments. You can bind to these events like you would with other jQuery events, using live() or bind().
pagecreate event. This event is explained in detail at the bottom of this page.tapNote that all four of these events expose a reference to either the next page (nextPage) or previous page (prevPage), depending on whether the page is being shown or hidden, and whether that next or previous page exists (the first ever page shown does not have a previous page to reference, but an empty jQuery object is provided just the same). You can access this reference via the second argument of a bound callback function. For example:
-
+
$('div').live('pageshow',function(event, ui){
alert('This page was just hidden: '+ ui.prevPage);
});
@@ -85,8 +88,7 @@ $('div').live('pageshow',function(event, ui){
$('div').live('pagehide',function(event, ui){
alert('This page was just shown: '+ ui.nextPage);
});
-
-
+
Also, for these handlers to be invoked during the initial page load, you must bind them before jQuery Mobile executes. This can be done in the mobileinit handler, as described on the global config page.
pagebeforecreatepagecreate
-
+
+ Triggered on the page being initialized, before initialization occurs.
+
$('#aboutPage').live('pagebeforecreate',function(event){
alert('This page was just inserted into the dom!');
});
-
-$('#aboutPage').live('pagecreate',function(event){
- alert('This page was just enhanced by jQuery Mobile!');
-});
-
-
+
+ Note that by binding to pagebeforecreate and returning false, you can prevent the page plugin from making its manipulations.
Note that by binding to pagebeforecreate and returning false, you can prevent the page plugin from making its manipulations.
-
+
$('#aboutPage').live('pagebeforecreate',function(event){
//run your own enhancement scripting here...
return false;
});
+
+
+
+ pagecreate
+
+ Triggered on the page being initialized, after initialization occurs. We recommend binding to this event instead of DOM ready() because this will work regardless of whether the page is loaded directly or if the content is pulled into another page as part of the Ajax navigation system.
+
+$('#aboutPage').live('pagecreate',function(event){
+ alert('This page was just enhanced by jQuery Mobile!');
+});
+
+
+
-
-
-
- Note on Page IDs in Alpha 2 release (no longer an issue): In jQuery Mobile Alpha 2 and older, page elements utilized the ID attribute for storing the location from which they came. When you place an ID attribute on a page that is brought into jQuery Mobile's single-page environment through Ajax, jQuery Mobile wraps that page with a new "page" div element, preserving any CSS references to your ID. However, this means that your ID attribute is no longer on the "page" element, so you must keep this in mind when binding to page events (pagebeforecreate, pagecreate, etc). To avoid issues, try using a class if possible.