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

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



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.