1.触摸屏事件—— Touch events

tap

Triggers after a quick, complete touch event.

本人实际测试效果:轻轻点击,效果和按普通按钮差不多。

taphold

Triggers after a held complete touch event (close to one second).

本人实际测试效果:按住一会儿,大约1秒,即触发。很顶用。

swipe

Triggers when a horizontal drag of 30px or more (and less than 20px vertically) occurs within 1 second duration.

本人实际测试效果:不懂,不会用

swipeleft

Triggers when a swipe event occurred moving in the left direction.

本人实际测试效果:在触摸屏幕上向左滑动,很好用。

PS:在电脑上你也可以用,按住鼠标向左拖就可以了。

swiperight

Triggers when a swipe event occurred moving in the right direction.

本人实际测试效果:在触摸屏幕上向右滑动,很好用。

PS:在电脑上你也可以用,按住鼠标向右拖就可以了。

使用方法:用live或者bind绑定到dom元素上即可,我是这么用的(以下的类似):

$('#wlist').live('swipeleft',function(){

changepage('up');

});

2.重力感应事件—— Orientation change event

orientationchange

Triggers when a device orientation changes (by turning it vertically or horizontally). When bound to this event, your callback function can leverage a second argument, which contains an orientationproperty equal to either "portrait" or "landscape". These values are also added as classes to the HTML element, allowing you to leverage them in your CSS selectors. Note that we currently bind to the resize event when orientationChange is not natively supported.

对应于手机上重力感应功能,当显示效果从垂直变为水平,或由水平变为垂直时触发。本人没用上该效果。

3.滚动条事件——Scroll events

scrollstart

Triggers when a scroll begins. Note that iOS devices freeze DOM manipulation during scroll, queuing them to apply when the scroll finishes. We're currently investigating ways to allow DOM manipulations to apply before a scroll starts.

个人测试效果:当滚动条触发时使用。

scrollstop

Triggers when a scroll finishes.

个人测试效果:当滚动条停止时使用,利用这个你可以让其返回当前滚动条的位置信息并记录下来。
$('body').live('scrollstop',function(){

$(‘#hidescroll’).val( $(this).scrollTop );

});

上面用一个ID名为hidescroll的影藏hidden控件保存了当前滚动条的位置信息。如果想使用后退页面时返回当前滚动条的位置,就请把这个hidescroll的值一并传输过去吧,不论是用get还是post。并且记得在页面写上:

$(document).ready(function(){ //  document.body.scrollTop = $(‘#hidescroll’).val();});

4 页面显示影藏事件——Page show/hide events

pagebeforeshow

Triggered on the page being shown, before its transition begins.

pagebeforehide

Triggered on the page being hidden, before its transition begins.

pageshow

Triggered on the page being shown, after its transition completes.

pagehide

Triggered on the page being hidden, after its transition completes.

这四个事件的好处是,在页面的加载过程中你可以干些事。

比如,在加载的时候添加loading画面:

$('div').live('pagebeforeshow',function(){$.mobile.pageLoading();});

在加载完成后影藏loading画面:

$('div').live('pageshow',function(){$.mobile.pageLoading(true);});

5. 页面创建事件:Page initialization events

pagebeforecreate

Triggered on the page being initialized, before initialization occurs.

pagecreate

Triggered on the page being initialized, after initialization occurs.

有时候你会遇到这种情况:一个页面,已经填写了一些自定义信息,你需要依靠这些信息初始化
一个新页面。我遇到的例子是,我的文件列表一刷新,点击其中任意一个文件可以显示一个对话框,这个对话框要显示你点击的这个文件的名字,和其他操作。新页
面并不知道你点的是哪个文件,总不能再查询一遍吧?这个时候你就需要Page initialization
events事件了,把你点击的文件名传过去。

$('#aboutPage').live('pagebeforecreate',function(event){
alert('This page was just inserted into the dom!'); });
$('#aboutPage').live('pagecreate',function(event){ alert('This page was
just enhanced by jQuery Mobile!'); });

上面是jquerymobile官网给出的两个例子,,允许你操纵一个页面pre-or-post初始化,相对于页面显示/隐藏事件,创建事件只会在初始化网页的时起作用。

值得注意的是,在Jquerymobile 1.0a2版本,加载对话框等东西进来,实际是用ajax方法将对话框以div role="page"模式加入当前页面。这个新加入的div,用ID保存它被ajax进来时的路径。

例如,我的主页mian.php有一个a标签:

<a href="dialog/search.php" type="GBK"
data-rel="dialog" data-transition="slide"  data-icon="search"
 data-iconpos="top" >简单搜索</a>

点击这个标签的结果是,在mian.php中,被ajax加入了一个id="dialog/search.php"的div,这个div, role="page",其内容就是文件search.php中body里的内容。

这样做,导致当下次再点击同一个连接的时候,实际相当于显示已被加载进来的page,加载
速度当然很快。但是,这意味着你的ID属性已经不再是原来页面的一部分,而是当前页面的一个div,所以你必须记住当绑定到页面,pagecreate事
件(pagebeforecreate等等)。避免这个问题的方法是用class代替id。好在我在我的程序里几乎没有遇到这个问题,因为我根本没有用
Page initialization
events事件,在初始化一些对话框的时候,我在主页的JS中做操作,修改对话框中的元素(因为我知道这些对话框显示的时候就已经是主页的一个div
了,我要的ID总会找到)。不过这样做的结果是,Jquerymobile
1.0a3版本导致了我所有对话框的失效……算了,哥不更新了, 等beta版出来还不行么。

6。常用函数、方法

显示或影藏jquery自带的loading画面

//cue the page loader

$.mobile.pageLoading();

//hide the page loader

$.mobile.pageLoading( true );

跳转到另一个页面上

//transition to the "about us" page with a slideup transition

$.mobile.changePage("about/us.html", "slideup");

//transition to the "search results" page, using data from a form with an ID of "search"" 

$.mobile.changePage({ url: "searchresults.php", type: "get", data: $("form#search").serialize() });

//transition to the "confirm" page with a "pop" transition without tracking it in history $.mobile.changePage("../alerts/confirm.html", "pop", false, false);

设置滚顿条位置

//scroll to Y 100px

$.mobile.silentScroll(100);

设置根据显示时宽度的最大最小信息设置html断点,我没用过,我猜会让断点以后的html不显示。$.mobile.addResolutionBreakpoints (method)Add width breakpoints to the min/max width classes that are added to the HTML element.

//add a 400px breakpoint

$.mobile.addResolutionBreakpoints(400);

//add 2 more breakpoints

$.mobile.addResolutionBreakpoints([600,800]);

除此以外还有其他一些方法,我都没用过,也没需要去用。等beta1的文档出来了再看吧。

jqmData(), jqmRemoveData(), and jqmHasData() (method)

$.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.activePage (property)

jquerymobile 的特有 事件 和 方法 (转)的更多相关文章

  1. jQuery中的事件绑定方法

    在jQuery中,事件绑定方法大致有四种:bind(),live(), delegate(),和on(). 那么在工作中应该如何选择呢?首先要了解四种方法的区别和各自的特点. 在了解这些之前,首先要知 ...

  2. jQuery的4种事件绑定方法

    jQuery中提供了四种绑定事件的方法,分别是bind.live.delegate.on,对应的解除监听的函数分别是unbind.die.undelegate.off: 一.on()方法(首选方法) ...

  3. 查看html元素绑定的事件与方法的利器

    WEB标准提倡结构.表现和行为相 分离,现在越来越多采用这种表现和行为的方式,但它也为我们开发调试带来一些问题,网页载入一堆JavaScript,,我们很难搞清楚最后在哪些元素的哪个动作绑定了事件,尤 ...

  4. Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数、ColModel API、事件及方法

    系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...

  5. 【转】监听按钮除OnClick外其他事件的方法,附简易改编的UIButton类

    http://lib.csdn.net/article/unity3d/38463 作者:IceFantasyLcj 大家好,我是雨中祈雨.一直以来,CSDN都是我最好的编程助手.这是我在CSDN的第 ...

  6. 【转】 NGUI 监听按钮除OnClick外其他事件的方法,附简易改编的UIButton类

    http://blog.csdn.net/icefantasylcj/article/details/49450555 大家好,我是雨中祈雨.一直以来,CSDN都是我最好的编程助手.这是我在CSDN的 ...

  7. 原生JS事件绑定方法以及jQuery绑定事件方法bind、live、on、delegate的区别

    一.原生JS事件绑定方法: 1.通过HTML属性进行事件处理函数的绑定如: <a href="#" onclick="f()"> 2.通过JavaS ...

  8. combobox 属性、事件、方法

    一 .combobox 属性.事件.方法公共属性 名称 说明 AccessibilityObject 获取分配给该控件的 AccessibleObject. AccessibleDefaultActi ...

  9. jquery 绑定事件的方法

    jQuery中提供了四种绑定事件的方法,分别是bind.live.delegate.on,对应的解除监听的函数分别是unbind.die.undelegate.off: 一.on()方法(首选方法) ...

随机推荐

  1. mac下java的安装和升级以及相关环境设置

    安装:brew cask install java8 如果存在多个java,可以设置JAVA_HOME指定java版本 打开终端,执行/usr/libexec/java_home -V 查看MAC下J ...

  2. mac的cpu处理器个数、核数、超线程

    处理器:1个 每个核的L2缓存大小:256KB L3缓存大小:3MB 核数:2个 2个核却有4个CPU:使用了超线程技术--双核四线程 macOS,查看CPU信息:sysctl machdep.cpu ...

  3. scala编程第19章学习笔记(1)——类型参数化

    一.queues函数式队列 函数式队列是一种具有以下三种操作方式的数据结构: head 返回队列的第一个元素. tail 返回除第一个元素之外的队列. scala> import scala.c ...

  4. 混沌数学之logistic模型

    logistic回归又称logistic回归分析,主要在流行病学中应用较多,比较常用的情形是探索某疾病的危险因素,根据危险因素预测某疾病发生的概率. 相关DEMO参见:混沌数学之离散点集图形DEMO ...

  5. vue-cli项目优化,缩短首屏加载时间

    1.大文件定位 我们可以使用webpack可视化插件Webpack Bundle Analyzer 查看工程js文件大小,然后有目的的解决过大的js文件. 安装:npm install --save- ...

  6. QlikView图表显示同比数据

    数据准备例如以下: SalesData: LOAD Num(ID) as ID, Date(Date) as Date, Month, Num(Year) as Year, Num(Sales) as ...

  7. 软件project(一)——宏观总结

    曾经看视频,看过去就忘.不想再这样子下去了,所以总结了好久.想让自己忘不了.这个过程花费时间有点长,可是假设让自己忘不了.一切都值了. 以下先来一张导图来总结一下<软件project>这门 ...

  8. The platform of the target `Pods` (iOS 4.3) is not compatible 错误

    一:使用 cocoaPod错误 The platform of the target `Pods` (iOS 4.3) is not compatible with `AFNetworking (1. ...

  9. HDOJ 4686 Arc of Dream 矩阵高速幂

    矩阵高速幂: 依据关系够建矩阵 , 高速幂解决. Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/ ...

  10. 实战c++中的vector系列--将迭代器转换为索引

    stl的迭代器非常方便 用于各种算法. 可是一想到vector.我们总是把他当做数组,总喜欢使用下标索引,而不是迭代器. 这里有个问题就是怎样把迭代器转换为索引: #include <vecto ...