Article Introduction: in this article, let's take a look at some of the more important basic events of jquery mobile. |
In this article, let's take a look at some of the more important basic events of jquery mobile
1, Mobileinit
You can use it to extend $.mobile or modify the default configuration
Example:
<script type= "Text/javascript" >//Mode 1: Binding Mobileinit $ (document). Bind ("Mobileinit", function (e) { // Modify Activepageclass $.mobile.activepageclass = "custom-ui-page-active"; Adds a custom attribute $.mobile.version_inner = "zhang01";}); Mode 2: Binding Mobileinit $ (document). Bind ("Mobileinit", function (e) { ///Add a custom attribute $.extend ($.mobile,{ Activepageclass: "Custom-ui-page-active", version_inner: "ZHANG01"; }); </script> //custom scripts need to be <script in front of dependencies src= "Http://www.w3cplus.com/sites/default/files/styles/print_ image/public/jqm/.. /js/jquery.mobile-1.1.0.js "type=" Text/javascript "></script>
Description
1. Binding events on Mobileinit need to be preceded by the introduction of Jquery.mobile.js
2, the expansion of the way there are two kinds of OH
2, $.mobile.loadpage (Url,[options])
Load a page into the current page and automatically enhance it
Example:
Bind the Tap Event//Call to the button loadpage, load contact.html $ ("#loadContact"). Live ("Tap", function () { $.mobile.loadpage () Contact.html "); });
The default parameters for LoadPage are shown in the figure:
Description
1, loadpage just load into the DOM, will not show
3, $.mobile.changepage (Topage,[options])
Replace current page
Parameter topage: file URL or internal ID
Example:
To bind the button tap event $ ("#loadCopyright"). Live ("Tap", function () { //Call Changepage, display a page $ already in the DOM ID for copyright. Mobile.changepage ("#copyright"); Call Changepage, display a contact.html $.mobile.changepage ("contact.html");
The default parameters for Changepage are shown in the figure:
Description
1, the first parameter of Changepage can make
4, $.mobile.showpageloadingmsg (theme,msgtext,textonly)
Pop-up Alert information
Parameter theme: Topic
Parameter msgtext: Hint copy content
Parameter textonly: whether to show only copy
Example:
Bind the button tap event $ ("#showPageLoadingMsg"). Live ("Tap", function () { $.mobile.showpageloadingmsg ("E", "custom hint, subject E", true); });
5, $.mobile.hidepageloadingmsg ()
Turn off the hint message
Example:
Hidepageloadingmsg $ ("#hidePageLoadingMsg"). Live ("Tap", function () { $.mobile.hidepageloadingmsg ();});
6, $.mobile.silentscroll (number)
Vertical scrolling number does not trigger Scrollstart and Scrollstop
Example:
Bind the button tap event//silentscroll $ ("#silentScroll"). Live ("Tap", function () { $.mobile.silentscroll (300);});
7, scrolling events:
1. Bind Scrollstart event to window:
Example:
$ (window). Scrollstart (function (e) { var scrolltop = $ (e.target). scrolltop (); $ ("#scrollinfo"). Text ("Scrollstart:" +scrolltop);});
2. Bind Scrollstop event to window:
Example:
$ (window). Scrollstop (function (e) { var scrolltop = $ (e.target). scrolltop (); $ ("#scrollinfo"). Text ("Scrollstop:" +scrolltop);});
Demo