You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: docs/api/events.html
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ <h1>Events</h1>
25
25
<divdata-role="content">
26
26
<divclass="content-primary">
27
27
28
-
<p>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 <code>live()</code> or <code>bind()</code>.</p>
28
+
<p>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 <code>on()</code> or <code>bind()</code>.</p>
29
29
30
30
<divclass="ui-body ui-body-e">
31
31
<h4style="margin:.5em 0">Important: Use <code>$(document).bind('pageinit')</code>, not <code>$(document).ready()</code></h4>
<p>You can access the <code>prevPage</code> or <code>nextPage</code> properties via the second argument of a bound callback function. For example: </p>
421
421
<pre><code>
422
-
$( 'div' ).live( 'pageshow',function(event, ui){
422
+
$( 'div' ).on( 'pageshow',function(event, ui){
423
423
alert( 'This page was just hidden: '+ ui.prevPage);
424
424
});
425
425
426
-
$( 'div' ).live( 'pagehide',function(event, ui){
426
+
$( 'div' ).on( 'pagehide',function(event, ui){
427
427
alert( 'This page was just shown: '+ ui.nextPage);
alert( 'This page was just inserted into the dom!' );
444
444
});
445
445
</code></pre>
446
446
<p>Note that by binding to <code>pagebeforecreate</code>, you can manipulate markup before jQuery Mobile's default widgets are auto-initialized. For example, say you want to add data attributes via JavaScript instead of in the HTML source, this is the event you'd use.</p>
<p>Triggered when the page has been created in the DOM (via ajax or other) but before all widgets have had an opportunity to enhance the contained markup. This event is most useful for user's wishing to create their own custom widgets for child markup enhancement as the jquery mobile widgets do.</p>
<p>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.</p>
0 commit comments