jquery mobile 事件

 
 

jQuery Mobile 事件参考手册

下表列出了所有的 jQuery Mobile 事件。

注释:请通过使用 on() 方法来绑定事件。

事件描述
hashchange启用 bookmarkable #hash 历史记录。
navigate针对 hashchange 和 popstate 的 wrapper 事件。
orientationchange当用户垂直或水平旋转其移动设备时触发。
pagebeforechange在页面变化周期内触发两次:任意页面加载或过渡之前触发一次,接下来在页面成功完成加载后,但是在浏览器历史记录被导航进程修改之前触发。
pagebeforecreate当页面即将被初始化,但是在增强开始之前触发。
pagebeforehide在过渡动画开始前,在“来源”页面上触发。
pagebeforeload在作出任何加载请求之前触发。
pagebeforeshow在过渡动画开始前,在“到达”页面上触发。
pagechange在 changePage() 请求已完成将页面载入 DOM 并且所有页面过渡动画已完成后触发。
pagechangefailed当 changePage() 请求对页面的加载失败时触发。
pagecreate当页面已创建,但是增强完成之前触发。
pagehide在过渡动画完成后,在“来源”页面触发。
pageinit当页面已经初始化并且完成增强时触发。
pageload在页面成功加载并插入 DOM 后触发。
pageloadfailed如果页面加载请求失败,则触发。
pageremove在窗口视图从 DOM 中移除外部页面之前触发。
pageshow在过渡动画完成后,在“到达”页面触发。
scrollstart当用户开始滚动页面时触发。
scrollstop当用户停止滚动页面时触发。
swipe当用户在元素上水平滑动时触发。
swipeleft当用户从左划过元素超过 30px 时触发。
swiperight当用户从右划过元素超过 30px 时触发。
tap当用户敲击某元素时触发。
taphold当元素敲击某元素并保持一秒时触发。
throttledresize启用 bookmarkable #hash 历史记录
updatelayout由动态显示/隐藏内容的 jQuery Mobile 组件触发。
vclick虚拟化的 click 事件处理器
vmousecancel虚拟化的 mousecancel 事件处理器
vmousedown虚拟化的 mousedown 事件处理器
vmousemove虚拟化的 mousemove 事件处理器
vmouseout虚拟化的 mouseout 事件处理器
vmouseover虚拟化的 mouseover 事件处理器
vmouseup虚拟化的 mouseup 事件处理器
事件的使用
 
// 全局命名空间
var swiptimg = {
    $index: 0,
    $width: 120,
    $swipt: 0,
    $legth: 3
}
var $imgul = $("#ifrswipt");
$(".imgswipt").each(function() {
    $(this).swipeleft(function() {
        if (swiptimg.$index < swiptimg.$legth) {
            swiptimg.$index++;
            swiptimg.$swipt = -swiptimg.$index * swiptimg.$width;
            //alert(swiptimg.$swipt + "/" + swiptimg.$index);
            $imgul.animate({ left: swiptimg.$swipt }, "slow");
        }
    }).swiperight(function() {
        if (swiptimg.$index > 0) {
            swiptimg.$index--;
            swiptimg.$swipt = -swiptimg.$index * swiptimg.$width;
            //alert(swiptimg.$swipt + "/" + swiptimg.$index);
            $imgul.animate({ left: swiptimg.$swipt }, "slow");
        }
    })
})
 方向改变事件
$(function() {
    var $p = $("p");
    $('body').bind('orientationchange', function(event) {
        var $oVal = event.orientation;
        if ($oVal == 'portrait') {
            $p.html("垂直方向");
            $p.attr("class", "p-portrait");
        } else {
            $p.html("水平方向");
            $p.attr("class", "p-landscape");
        }
    })
})
//窗口滚动事件
$('div[data-role="page"]').live('pageinit', function(event, ui) {
    var eventsElement = $('p');
    $(window).bind('scrollstart', function() {
        eventsElement.html("开始滚动");
        eventsElement.css('background', 'green');
    })
    $(window).bind('scrollstop', function() {
        eventsElement.html("滚动停止");
        eventsElement.css('background', 'red');
    })
})
  页面显示和隐藏事件
$(function() {
    $('div').live('pagebeforehide', function(event, ui) {
        console.log('1. ' + ui.nextPage[0].id + ' 正在显示中... ');
    });
    $('div').live('pagebeforeshow', function(event, ui) {
        console.log('2. ' + ui.prevPage[0].id + ' 正在隐藏中... ');
    });
    $('div').live('pagehide', function(event, ui) {
        console.log('3. ' + ui.nextPage[0].id + ' 显示完成! ');
    });
    $('div').live('pageshow', function(event, ui) {
        console.log('4. ' + ui.prevPage[0].id + ' 隐藏完成! ');
    })
})
 
var absPath = $.mobile.path.makePathAbsolute($(this).val(), strPath);
var absPath = $.mobile.path.makeUrlAbsolute($(this).val(), strPath);
 var blnResult = $.mobile.path.isRelativeUrl($(this).val()) ? "是" : "否";
 var blnResult = $.mobile.path.isAbsoluteUrl($(this).val()) ? "是" : "否";
  var blnResult = $.mobile.path.isSameDomain($txt1, $txt2) ? "是" : "否";
 
 
 
 
 
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值