• Jquery Mobile事件


    Jquery Mobile事件参考手册

    on()方法用于添加事件处理程序

    1.Touch类事件

    在用户触摸屏幕时触发

      1.1 tap事件 用户敲击某个元素时发生

    $("p").on("tap",function(){
        $(this).hide();
    })

      1.2 taphold事件 用户敲击某个元素并保持一秒被触发

    $("p").on("taphold",function(){
        $(this).hide();
    })

      1.3 swipeleft 用户在某个元素上左滑动超过30px时触发

    $("p").on("swipeleft",function(){
      alert("You swiped left!");
    });

    2.滚动事件

      2.1 scrollstart 事件在用户开始滚动页面时被触发

    $(document).on("scrollstart",function(){
      alert("开始滚动!");
    });

      2.2 scrollstop  事件在用户停止滚动页面时被触发

    $(document).on("scrollstop",function(){
      alert("停止滚动!");
    });

    3.方向事件

    orientationchange 事件 用户水平或垂直旋转屏幕时触发

    使用orientationchange 事件,需要把它添加到window对象

    $(window).on("orientationchange",function(){
      alert("方向已改变!");
    });

    由于该事件与window对象绑定,就有window.orientation属性

    if(window.orientation==0){
    说明屏幕是portrait的
    }

    提示:window.orientation 属性对 portrait 视图返回 0,对 landscape 视图返回 90 或 -90

    4.页面事件

    在 jQuery Mobile 中与页面打交道的事件被分为四类:

    • Page Initialization - 在页面创建前,当页面创建时,以及在页面初始化之后
    • Page Load/Unload - 当外部页面加载时、卸载时或遭遇失败时
    • Page Transition - 在页面过渡之前和之后
    • Page Change - 当页面被更改,或遭遇失败时

      4.1 Initialization事件

    事件描述
    pagebeforecreate 当页面即将初始化,并且在 jQuery Mobile 已开始增强页面之前,触发该事件。
    pagecreate 当页面已创建,但增强完成之前,触发该事件。
    pageinit 当页面已初始化,并且在 jQuery Mobile 已完成页面增强之后,触发该事件。
    $(document).on("pagebeforecreate",function(event){
      alert("触发 pagebeforecreate 事件!");
    }); 
    $(document).on("pagecreate",function(event){
      alert("触发 pagecreate 事件!");
    });
    $(document).on("pageinit",function(event){
      alert("触发 pageinit 事件!")
    });

      4.2 Load事件 外部页面加载

    事件描述
    pagebeforeload 在任何页面加载请求作出之前触发。
    pageload 在页面已成功加载并插入 DOM 后触发。
    pageloadfailed 如果页面加载请求失败,则触发该事件。默认地,将显示 "Error Loading Page" 消息。
    $(document).on("pageload",function(event,data){
      alert("触发 pageload 事件!
    URL: " + data.url);
    });
    $(document).on("pageloadfailed",function(event,data){
      alert("抱歉,被请求页面不存在。");
    });

      4.3 过渡事件 从一页过渡到下一页时触发

    事件描述
    pagebeforeshow 在“去的”页面触发,在过渡动画开始前。
    pageshow 在“去的”页面触发,在过渡动画完成后。
    pagebeforehide 在“来的”页面触发,在过渡动画开始前。
    pagehide 在“来的”页面触发,在过渡动画完成后。
    $(document).on("pagebeforeshow","#pagetwo",function(){ // 当进入页面二时
      alert("页面二即将显示");
    });
    $(document).on("pageshow","#pagetwo",function(){ // 当进入页面二时
      alert("现在显示页面二");
    });
    $(document).on("pagebeforehide","#pagetwo",function(){ // 当离开页面二时
      alert("页面二即将隐藏");
    });
    $(document).on("pagehide","#pagetwo",function(){ // 当离开页面二时
      alert("现在隐藏页面二");
    });

     

     

  • 相关阅读:
    SQLServer查询执行计划分析
    武汉性能测试研讨会资料共享
    下周 武汉性能测试研讨会!
    sql优化之(DMV)
    深圳测试研讨会圆满结束,PPT共享
    深圳性能测试研讨会即将举行!
    LoadRunner执行过程报错“Failed to connect to server "xxx.xxx.xxx.xxx:xx":[10060] connetion time out”
    Nginx upstream 长连接
    命令行下打WAR包
    新一代服务器性能测试工具Gatling
  • 原文地址:https://www.cnblogs.com/dll-ft/p/5596678.html
Copyright © 2020-2023  润新知