Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
added events documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjehl committed Oct 20, 2010
1 parent 6ea7ba6 commit ed07fbc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
50 changes: 49 additions & 1 deletion docs/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,56 @@ <h1>Events</h1>
</div><!-- /header -->

<div data-role="content">
<h2>New events available in jQuery Mobile</h2>

<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>
<ul>
<li><code>tap</code> Triggers after a quick, complete touch event.</li>
<li><code>taphold</code> Triggers after a held complete touch event (close to one second).</li>
<li><code>swipe</code> Triggers when a horizontal drag of 30px or more (and less than 20px vertically) occurs within 1 second duration.</li>
<li><code>swipeleft</code> Triggers when a swipe event occurred moving in the left direction.</li>
<li><code>swiperight</code> Triggers when a swipe event occurred moving in the right direction.</li>
<li><code>orientationchange</code> Triggers when a device orientation changes (by turning it vertically or horizontally). When bound to this event, your callback function can leverage a second argument, which contains an <code>orientation</code> property equal to either "portrait" or "landscape". These values are also added as classes to the HTML element, allowing you to leverage them in your CSS selectors. Note that we currently bind to the resize event when orientationChange is not natively supported.</li>
<li><code>scrollstart</code> Triggers when a scroll begins. Note that iOS devices freeze DOM manipulation during scroll, queuing them to apply when the scroll finishes. We're currently investigating ways to allow DOM manipulations to apply before a scroll starts.</li>
<li><code>scrollstop</code> Triggers when a scroll finishes.</li>
</ul>

<h3>Page show/hide events</h3>
<p>Whenever a page is shown or hidden in jQuery Mobile, two events are triggered on that page. The events triggered depend on whether that page is being shown or hidden, so when a page transition occurs, there are actually 4 events triggered: 2 for each page. </p>
<ul>
<li><code>pagebeforeshow</code> Triggered on the page being shown, before its transition begins.</li>
<li><code>pagebeforehide</code> Triggered on the page being hidden, before its transition begins.</li>
<li><code>pageshow</code> Triggered on the page being shown, after its transition completes.</li>
<li><code>pagehide</code> Triggered on the page being hidden, after its transition completes.</li>
</ul>

<p>Note that all four of these events expose a reference to either the next page (<code>nextPage</code>) or previous page (<code>prevPage</code>), 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: </p>
<pre>
<code>
$('div').live('pageshow',function(event, ui){
alert('This page was just hidden: '+ ui.prevPage);
});

$('div').live('pagehide',function(event, ui){
alert('This page was just shown: '+ ui.nextPage);
});
</code>
</pre>
<h3>Page initialization events</h3>

<p>Internally, jQuery Mobile auto-initializes plugins based on the markup conventions found in a given "page". For example, an <code>input</code> element with a <code>type</code> of <code>range</code> will automatically generate a custom slider control.</p>

<p>This auto-initialization is controlled by the "page" plugin, which dispatches events before and after it executes, allowing you to manipulate a page either pre-or-post initialization, or even provide your own intialization behavior and prevent the auto-initializations from occuring. Note that these events will only fire once per "page", as opposed to the show/hide events, which fire every time a page is shown and hidden.</p>

<ul>
<li><code>pagebeforecreate</code> Triggered on the page being initialized, before initialization occurs.</li>
<li><code>pagecreate</code> Triggered on the page being initialized, after initialization occurs.</li>
</ul>

<p>Note that by binding to <code>pagebeforecreate</code> and returning <code>false</code>, you can prevent the page plugin from making its manipulations.</p>

<p>Documentation is currently in-progress.</p>
<h3>Animation Events</h3>
<p>Currently, jQuery Mobile exposes the <code>animationComplete</code> event, which you can utilize after adding or removing a class that applies a CSS transition.</p>

</div><!-- /content -->

Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>jQuery Mobile Docs</h1>
<li><a href="content/index.html">Content formatting</a></li>
<li><a href="forms/index.html">Form elements</a></li>
<li><a href="lists/index.html">List views</a></li>
<!--<li><a href="docs/events.html">Events</a></li>-->
<li><a href="events.html">Events</a></li>
</ul>

</div>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1 id="jqm-logo"><img src="docs/_assets/images/jquery-logo.png" alt="jQuery Mob
<li><a href="docs/content/index.html">Content formatting</a></li>
<li><a href="docs/forms/index.html">Form elements</a></li>
<li><a href="docs/lists/index.html">List views</a></li>
<!--<li><a href="docs/events.html">Events</a></li>-->
<li><a href="docs/events.html">Events</a></li>
</ul>

<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
Expand Down

0 comments on commit ed07fbc

Please sign in to comment.