jquery Mobile Tutorial: jquery Mobile Basic events

Source: Internet
Author: User
Tags bind copy extend file url modify window

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


<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>

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


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:

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


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:

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


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


Hidepageloadingmsg $ ("#hidePageLoadingMsg"). Live ("Tap", function () { 	$.mobile.hidepageloadingmsg ();});
6, $.mobile.silentscroll (number)

Vertical scrolling number does not trigger Scrollstart and Scrollstop


Bind the button tap event//silentscroll $ ("#silentScroll"). Live ("Tap", function () { 	$.mobile.silentscroll (300);});
7, scrolling events:

1. Bind Scrollstart event to window:


$ (window). Scrollstart (function (e) { 	var scrolltop = $ (e.target). scrolltop (); 	$ ("#scrollinfo"). Text ("Scrollstart:" +scrolltop);});

2. Bind Scrollstop event to window:


$ (window). Scrollstop (function (e) { 	var scrolltop = $ (e.target). scrolltop (); 	$ ("#scrollinfo"). Text ("Scrollstop:" +scrolltop);});


Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.