jQuery Mobile開(kāi)發(fā)方法和實(shí)用工具
$.mobile.changePage (method)
從一個(gè)頁(yè)面到另一個(gè)頁(yè)面可以編程來(lái)改變.該方法用于頁(yè)面間跳轉(zhuǎn),以點(diǎn)擊一個(gè)鏈接或者提交表單的形式出現(xiàn), (當(dāng)那些特性被啟用時(shí)).
Arguments
to
◆String, url: ("about/us.html")
◆jQuery 對(duì)象 ($("#about"))
◆一個(gè)指定了兩個(gè)頁(yè)面引用的數(shù)組[from,to] ,用以在已知的page進(jìn)行跳轉(zhuǎn). From 是當(dāng)前所能看到的頁(yè)面( 或者是 $.mobile.activePage ).
◆發(fā)送表單數(shù)據(jù)的對(duì)象. ({to: url, data: serialized form data, type: "get" or "post"}
transition (string, 過(guò)渡效果: "pop", "slide"," "none")
reverse (boolean, default: false). 設(shè)置為true時(shí)將導(dǎo)致一個(gè)反方向的跳轉(zhuǎn).
changeHash (boolean, default: true). 當(dāng)頁(yè)面change完成時(shí)更新頁(yè)面的URL hash.
示例:
- //以slideup效果 跳轉(zhuǎn)到 "about us" 頁(yè)面
- $.mobile.changePage("about/us.html", "slideup");
- //跳轉(zhuǎn)到 "search results" 頁(yè)面,提交id為 "search"的表單數(shù)據(jù)
- $.mobile.changePage({
- url: "searchresults.php",
- type: "get",
- data: $("form#search").serialize()
- });
- //以pop效果 跳轉(zhuǎn)到 "confirm" 頁(yè)面 并且在url hash里不記錄其歷史
- $.mobile.changePage("../alerts/confirm.html", "pop", false, false);
$.mobile.pageLoading (method)
顯示或隱藏 頁(yè)面加載消息,該消息由$.mobile.loadingMessage進(jìn)行配置.
Arguments:
Done (boolean,默認(rèn)為 false, 這意味著加載已經(jīng)開(kāi)始). 設(shè)置為True會(huì)隱藏 頁(yè)面加載消息.
示例:
- //提示頁(yè)面加載
- $.mobile.pageLoading();
- //隱藏頁(yè)面加載
- $.mobile.pageLoading( true );
$.mobile.path (methods, properties)
Utilities for getting, setting, and manipulating url paths. TODO: document as public API is finalized.
$.mobile.base (methods, properties)
Utilities for working with generated base element. TODO: document as public API is finalized.
$.mobile.silentScroll (method)
在不觸發(fā)scroll事件處理程序的情況下在Y軸上進(jìn)行滾動(dòng).
Arguments:
yPos (number, 默認(rèn)為 0). 傳遞任何數(shù)字以在Y坐標(biāo)上進(jìn)行滾動(dòng).
示例:
- // Y上滾動(dòng) 100px
- $.mobile.silentScroll(100);
$.mobile.addResolutionBreakpoints (method)
為min/max width class 添加width折斷點(diǎn) 被添加到HTML元素上. (譯注:折斷點(diǎn)指的是當(dāng)屏幕或?yàn)g覽器寬度在到達(dá)某個(gè)范圍時(shí),容器元素將會(huì)發(fā)生折斷現(xiàn)象--比如當(dāng)寬度為480時(shí)2個(gè)radiobutton會(huì)排成一排,而寬度改變?yōu)?20時(shí),2個(gè)radiobutton可能會(huì)自動(dòng)折斷成兩排)
Arguments:
values (number 或者 array). 傳遞任何數(shù)字或者數(shù)字?jǐn)?shù)組.
示例:
- //添加一個(gè) 400px 的分辨率斷點(diǎn)
- $.mobile.addResolutionBreakpoints(400);
- //添加二個(gè)分辨率斷點(diǎn)
- $.mobile.addResolutionBreakpoints([600,800]);