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. DHCP Option 60 的理解

    原文地址: http://blog.163.com/chenqioulin_1983/blog/static/83216232010109104430251/   首先还是看看RFC咋说的吧.DHCP ...

  2. Files to be needed by importing the android application with eclipse

    1. AndroidManifest.xml 2. project.properties # This file is automatically generated by Android Tools ...

  3. java 十六进制数的转换

    今天晚上做了一道java基础题,题目看起来简单,但是实现起来却花了我近两个小时的时间,认真的做这道题,你会发现它特别考你的基本功.有兴趣的可以试一下哦. 题目: 请用此语言编写如下函数,采用自己的算法 ...

  4. 今天升级了ADT到ADT 22.6.1,打包混淆的时候就出现了问题

    Proguard returned with error code 1. See console Error: Unable to access jarfile ..\lib\proguard.jar ...

  5. 在Struts2中使用ValueStack、ActionContext、ServletContext、request、session等 .

    笔者不知道该用哪个词来形容ValueStack.ActionContext等可以在Struts2中用来存放数据的类.这些类使用的范围不同,得到的方法也不同,下面就来一一介绍. 声明:本文参考Strut ...

  6. windows远程关机重启

    windows远程关机 http://lsscto.blog.51cto.com/779396/245681 shutdown http://baike.baidu.com/view/596875.h ...

  7. Newton's Method

    在求最优解时,前面很多地方都用梯度下降(Gradient Descent)的方法,但由于最优步长很难确定,可能会出现总是在最优解附近徘徊的情况,致使最优解的搜索过程很缓慢.牛顿法(Newton's M ...

  8. android.os.NetworkOnMainThreadException 异常处理

    当我试图在UI线程(MainActivity)连接网络的时候,运行时抛出异常droid.os.NetworkOnMainThreadException 安卓的官方文档说 The exception t ...

  9. WebSocket原理及与http1.0/1.1 long poll和 ajax轮询的区别【转自知乎】

    一.WebSocket是HTML5出的东西(协议),也就是说HTTP协议没有变化,或者说没关系,但HTTP是不支持持久连接的(长连接,循环连接的不算)首先HTTP有1.1和1.0之说,也就是所谓的ke ...

  10. signal函数、sigaction函数及信号集(sigemptyset,sigaddset)操作函数

    信号是与一定的进程相联系的.也就是说,一个进程可以决定在进程中对哪些信号进行什 么样的处理.例如,一个进程可以忽略某些信号而只处理其他一些信号:另外,一个进程还可以选择如何处理信号.总之,这些总与特定 ...