HTML5 developing mobile Web Apps-jquery mobile (4)-events

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="white-space:pre"></span>Jquery Mobile provides a rich range of event handling and detection Mechanisms.</p></p><p><p><span style="white-space:pre"></span>1. Scrolling Events</p></p><p><p><span style="white-space:pre"></span>In jquery mobile, you use the Scrollstart and Scrollstop events to listen for events that users start scrolling and stop scrolling. Take Scrollstart as an example, using the following code:</p></p><p><p></p></p><pre code_snippet_id="1609527" snippet_file_name="blog_20160314_1_5374272" name="code" class="javascript"><pre code_snippet_id="1609527" snippet_file_name="blog_20160314_1_5374272" name="code" class="javascript">$ (document). on ("scrollstart", function () { alert ("start scrolling!) ");});</pre></pre><span style="white-space:pre"><span style="white-space:pre"> </span></span>2. interface-related Events<p><p></p></p><p><p><span style="white-space:pre"></span>A page from activation to loading completed, in jquery Mobile is divided into four parts of the event, they are:<span style="white-space:pre"></span></p></p><p><p><span style="white-space:pre"></span></p></p><p><p><span style="white-space:pre"></span>Page Initialization-before The page is created, when the page is created, and after the page is initialized</p></p><p><p><span style="white-space:pre"></span>Page Load/unload-when an external page loads, unloads, or encounters a failure</p></p><p><p><span style="white-space:pre"></span>Page Transition-before and after the page transitions</p></p><p><p><span style="white-space:pre"></span>Page Change-when the page is changed, or when it encounters a failure</p></p><span style="white-space:pre"><span style="white-space:pre"></span></span>In the page initialization section, jquery Mobile also divides it into three phases: pre-page creation (pagebeforecreate)/page creation (pagecreate)/page initialization (pageinit), which can be performed in each phase. The sample code is as Follows:<p><p><span style="white-space:pre"></span></p></p><pre code_snippet_id="1609527" snippet_file_name="blog_20160314_2_3880555" name="code" class="javascript"><pre code_snippet_id="1609527" snippet_file_name="blog_20160314_2_3880555" name="code" class="javascript">$ (document). on ("pagebeforecreate", function (event) { alert ("pagebeforecreate");}); $ (document). on ("pagecreate", function (event) { alert ("pagecreate");}); $ (document). on ("pageinit", function (event) { alert ("pageinit")});</pre></pre><span style="white-space:pre"><span style="white-space:pre"></span></span>3. About device Orientation<p><p></p></p><p><p><span style="white-space:pre"></span>The following is the instance code from w3cschool, can monitor the device direction changes, and set different styles after the device direction changes;</p></p><p><p></p></p><pre code_snippet_id="1609527" snippet_file_name="blog_20160314_3_3706615" name="code" class="javascript"><pre code_snippet_id="1609527" snippet_file_name="blog_20160314_3_3706615" name="code" class="javascript">$ (window). on ("orientationchange", function () { if (window.orientation = = 0)//Portrait { $ ("p"). css ({" Background-color ":" Yellow "," font-size ":" 300% "}); Else//Landscape { $ ("p"). css ({"background-color": "pink", "font-size": "200%"});} );</pre></pre><br><br><br><p><p></p></p><p><p>HTML5 developing mobile Web Apps-jquery mobile (4)-events</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.