jQuery Mobile里$(document).ready()怎么用呀?

相关链接:

注意事项:

    • Use $(document).bind('pageinit/pageshow'), not $(document).ready()
    • 默认设置下,jQueryMobile网站第一个页面之后的所有页面都是使用AJAX去加载的,而document.ready只会在第一个页面加载时执行,that's why not document.ready.
    • 相对应的,pageinit/pageshow事件则像是加载页面AJAX代码的一个回调(callback)函数,请求成功后便触发执行

jQuery Mobile里mobileinit event怎么用呀?

相关链接:

mobileinit事件的作用:

    • 更改默认设置(To override default settings)
    • 在page加载之前绑定事件处理函数(bind pageshow/pageinit event handlers before page is loaded)

注意事项:

    • mobileinit事件处理函数的代码一定要放在在jquery加载之后,jquerymobile加载之前
    • <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
      <script>
      $(document).on("mobileinit", function(){
      $(document).on('pageshow', 'div:jqmData(role="page"), div:jqmData(role="dialog")', function(event){
      //pageshow handler goes here
      });
      $(document).on('pageinit', function() {
      //pageinit handler goes here
      });
      });
      </script>
      <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

jQuery Mobile里page事件触发顺序是怎样的?

First all events can be found here: http://api.jquerymobile.com/category/events/

    • pagebeforeloadpageload and pageloadfailed are fired when an external page is loaded
    • pagebeforechangepagechange and pagechangefailed are page change events. These events are fired when a user is navigating between pages in the applications.
    • pagebeforeshowpagebeforehidepageshow and pagehide are page transition events. These events are fired before, during and after a transition and are named.
    • pagebeforecreatepagecreate and pageinit are for page initialization.
    • pageremove can be fired and then handled when a page is removed from the DOM

Page loading jsFiddle example: http://jsfiddle.net/Gajotres/QGnft/

(以上内容copy自http://stackoverflow.com/questions/14468659/jquery-mobile-document-ready-vs-page-events,有那么好的讲解我为什么不用!)

jQuery Mobile里xxx怎么用呀? (事件篇)的更多相关文章

  1. jQuery Mobile里xxx怎么用呀?(控件篇)

    jQuery Mobile里都有什么控件? http://api.jquerymobile.com/category/widgets/ jQuery Mobile里slider控件的change事件怎 ...

  2. jQuery Mobile里xxx怎么用呀?(缓存篇)

    jQuery Mobile初始页面DOM Cache所引发的问题 HTML元素事件多次触发: jsFiddle: http://jsfiddle.net/gn9JA/2/ cause: 在jsFidd ...

  3. jQuery Mobile里xxx怎么用呀?(集成篇)

    jQuery Mobile如何使用GA(Google Analytics)? 什么是GA: http://baike.baidu.com/view/34729.htm http://www.googl ...

  4. jquery mobile Checkbox动态添加刷新及事件绑定

    jquery mobile Checkbox动态添加刷新及事件绑定 在微信项目中,涉及到一个多选功能.数据来自后台数据库,需要动态加载. 项目结构:微信api+web app.使用jquery mob ...

  5. jQuery Mobile的学习时间bottonbutton的事件学习

    程序猿都非常懒.你懂的! 生命的绝唱来机仅仅争朝夕,如诗的年华更需惜时如金. 不要让今天的懈怠成为一生的痛. 每天都在进步. 近期在学习jquery mobile开发.使用的button,绑定事件,和 ...

  6. [转]使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 事件详解

    在前文<使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 默认配置与事件基础>中,Kayo 对 jQuery Mobile 事件的基 ...

  7. jQuery Mobile方向感应事件

    在现在的智能手机中,都有对方向变换的自动感知功能,比如当手机方向从水平方向切换到垂直方向时,则会触发该事件.在jQuery Mobile中,可以通过orientationchange事件进行绑定,并且 ...

  8. Jquery Mobile事件

    Jquery Mobile事件参考手册 on()方法用于添加事件处理程序 1.Touch类事件 在用户触摸屏幕时触发 1.1 tap事件 用户敲击某个元素时发生 $("p").on ...

  9. jQuery Mobile 页面事件

    jQuery Mobile 页面事件 在 jQuery Mobile 中与页面打交道的事件被分为四类: Page Initialization - 在页面创建前,当页面创建时,以及在页面初始化之后 P ...

随机推荐

  1. OpenCV Mat 类型定义和赋值

    1.一般的Mat定义方法:cv::Mat M(height,width,<Type>),例: cv::Mat M(480,640,CV_8UC3); 表示定义了一个480行640列的矩阵, ...

  2. File transfer in android with asmack and Openfire

    http://harryjoy.com/2012/08/18/file-transfer-in-android-with-asmack-and-openfire/ http://www.javacod ...

  3. dialog统一标准调用方法(内部记录)

    更新base-config.js 对话框统一为三种形式(如后期需要再添加其他方式) //对话框--确定取消 //dialogOkFun:确定函数 dialogCancelFun:取消函数 functi ...

  4. json处理复杂对象jsonConfig

     我们通常的Json字符串和java当对象互转.经常有选择性地过滤掉一些属性值,和json-lib包JsonConfig为我们提供了这样一个 特征,有几种方法实施细则. (1)建立JsonConf ...

  5. EasyUI基础入门之Easyloader(载入器)

    在了解完easyui的parser(解析器)之后,接下来就是easyloader(简单载入器)的学习了. 什么是EasyLoader 正如其名字一样easyloader的作用是为了动态的载入组件所需的 ...

  6. There is no Action mapped for action name XXX. - [unknown location]

    今天被这个问题费了不少时间,原因是缺少了 struts2-json-plugin-2.3.1.2.jar 包 当然,有时候也可能是缺少其他包, 把这个包添加到lib文件夹后还要刷新,clean一下,因 ...

  7. css中那些你可能没注意到的东西

    1.inline元素,添加position:absolute;可定宽高,position:relative;则不行,不信你试试! 2.inline元素添加浮动后,不用加display:block;也可 ...

  8. 聊一聊ES5数组(Array)新增的那些方法

    一.前言 ES5中新增的一些处理数组(Array)的方法, 对于用JavaScript处理数据非常有用.我总结了一下,给这些方法分了类,大体如下: 2个索引方法:indexOf() 和 lastInd ...

  9. 有关<action android:name="android.intent.action.DELETE" />

    今天看一个病毒样本时遇到了这个Action,位于一个Activity节点下 通过真机测试与导师指导发现,这个Action的作用就相当于把其所在的应用加入到了“系统卸载程序”列表,当你卸载系统中的任一应 ...

  10. NekoHTML

    1.如何使用NekoHTML? 必须在 Java Build Path里加入 nekohtml.jar , xercesImpl.jar 以及xalan.jar.下载的NekoHTML目录中并没有xe ...