jQuery Mobile开发方法和实用工具

本文将讲述jQuery Mobile在$.mobile对象里公开了一系列的开发方法和实用工具,这些开发方法和实用工具可以来辅助您完成自己的应用程序.
首页 新闻资讯 行业资讯 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);
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

  • 11.

  • 12.

  • 13.

  • 14.

  • 15.

  • 16.

  • 17.

  • 18.

  • 19.

$.mobile.pageLoading (method)

显示或隐藏 页面加载消息,该消息由$.mobile.loadingMessage进行配置.

Arguments:

Done (boolean,默认为 false, 这意味着加载已经开始). 设置为True会隐藏 页面加载消息.

示例:

复制

//提示页面加载  $.mobile.pageLoading();  //隐藏页面加载  $.mobile.pageLoading( true );
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

$.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);
  • 1.

  • 2.

  • 3.

$.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]);
  • 1.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

 

12    2011-07-20 14:03:33    jQuery Mobile 实用工具