jQuery Mobile開發方法和實用工具
$.mobile.changePage (method)
從一個頁面到另一個頁面可以編程來改變.該方法用于頁面間跳轉,以點擊一個鏈接或者提交表單的形式出現, (當那些特性被啟用時).
Arguments
to
◆String, url: ("about/us.html")
◆jQuery 對象 ($("#about"))
◆一個指定了兩個頁面引用的數組[from,to] ,用以在已知的page進行跳轉. From 是當前所能看到的頁面( 或者是 $.mobile.activePage ).
◆發送表單數據的對象. ({to: url, data: serialized form data, type: "get" or "post"}
transition (string, 過渡效果: "pop", "slide"," "none")
reverse (boolean, default: false). 設置為true時將導致一個反方向的跳轉.
changeHash (boolean, default: true). 當頁面change完成時更新頁面的URL hash.
示例:
- //以slideup效果 跳轉到 "about us" 頁面
- $.mobile.changePage("about/us.html", "slideup");
- //跳轉到 "search results" 頁面,提交id為 "search"的表單數據
- $.mobile.changePage({
- url: "searchresults.php",
- type: "get",
- data: $("form#search").serialize()
- });
- //以pop效果 跳轉到 "confirm" 頁面 并且在url hash里不記錄其歷史
- $.mobile.changePage("../alerts/confirm.html", "pop", false, false);
$.mobile.pageLoading (method)
顯示或隱藏 頁面加載消息,該消息由$.mobile.loadingMessage進行配置.
Arguments:
Done (boolean,默認為 false, 這意味著加載已經開始). 設置為True會隱藏 頁面加載消息.
示例:
- //提示頁面加載
- $.mobile.pageLoading();
- //隱藏頁面加載
- $.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)
在不觸發scroll事件處理程序的情況下在Y軸上進行滾動.
Arguments:
yPos (number, 默認為 0). 傳遞任何數字以在Y坐標上進行滾動.
示例:
- // Y上滾動 100px
- $.mobile.silentScroll(100);
$.mobile.addResolutionBreakpoints (method)
為min/max width class 添加width折斷點 被添加到HTML元素上. (譯注:折斷點指的是當屏幕或瀏覽器寬度在到達某個范圍時,容器元素將會發生折斷現象--比如當寬度為480時2個radiobutton會排成一排,而寬度改變為320時,2個radiobutton可能會自動折斷成兩排)
Arguments:
values (number 或者 array). 傳遞任何數字或者數字數組.
示例:
- //添加一個 400px 的分辨率斷點
- $.mobile.addResolutionBreakpoints(400);
- //添加二個分辨率斷點
- $.mobile.addResolutionBreakpoints([600,800]);