jQuery Mobile里xxx怎么用呀? (事件篇)
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/
pagebeforeload,pageloadandpageloadfailedare fired when an external page is loadedpagebeforechange,pagechangeandpagechangefailedare page change events. These events are fired when a user is navigating between pages in the applications.pagebeforeshow,pagebeforehide,pageshowandpagehideare page transition events. These events are fired before, during and after a transition and are named.pagebeforecreate,pagecreateandpageinitare for page initialization.pageremovecan 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怎么用呀? (事件篇)的更多相关文章
- jQuery Mobile里xxx怎么用呀?(控件篇)
jQuery Mobile里都有什么控件? http://api.jquerymobile.com/category/widgets/ jQuery Mobile里slider控件的change事件怎 ...
- jQuery Mobile里xxx怎么用呀?(缓存篇)
jQuery Mobile初始页面DOM Cache所引发的问题 HTML元素事件多次触发: jsFiddle: http://jsfiddle.net/gn9JA/2/ cause: 在jsFidd ...
- jQuery Mobile里xxx怎么用呀?(集成篇)
jQuery Mobile如何使用GA(Google Analytics)? 什么是GA: http://baike.baidu.com/view/34729.htm http://www.googl ...
- jquery mobile Checkbox动态添加刷新及事件绑定
jquery mobile Checkbox动态添加刷新及事件绑定 在微信项目中,涉及到一个多选功能.数据来自后台数据库,需要动态加载. 项目结构:微信api+web app.使用jquery mob ...
- jQuery Mobile的学习时间bottonbutton的事件学习
程序猿都非常懒.你懂的! 生命的绝唱来机仅仅争朝夕,如诗的年华更需惜时如金. 不要让今天的懈怠成为一生的痛. 每天都在进步. 近期在学习jquery mobile开发.使用的button,绑定事件,和 ...
- [转]使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 事件详解
在前文<使用 jQuery Mobile 与 HTML5 开发 Web App —— jQuery Mobile 默认配置与事件基础>中,Kayo 对 jQuery Mobile 事件的基 ...
- jQuery Mobile方向感应事件
在现在的智能手机中,都有对方向变换的自动感知功能,比如当手机方向从水平方向切换到垂直方向时,则会触发该事件.在jQuery Mobile中,可以通过orientationchange事件进行绑定,并且 ...
- Jquery Mobile事件
Jquery Mobile事件参考手册 on()方法用于添加事件处理程序 1.Touch类事件 在用户触摸屏幕时触发 1.1 tap事件 用户敲击某个元素时发生 $("p").on ...
- jQuery Mobile 页面事件
jQuery Mobile 页面事件 在 jQuery Mobile 中与页面打交道的事件被分为四类: Page Initialization - 在页面创建前,当页面创建时,以及在页面初始化之后 P ...
随机推荐
- 使用 Windows 窗体 TextBox 控件创建密码文本框
密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符. 创建密码文本框 将 TextBox 控件的 PasswordChar 属性设置为某个特定字符. PasswordChar 属 ...
- Codeforces Round #268 (Div. 1) A. 24 Game 构造
A. 24 Game Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/468/problem/A D ...
- 全局唯一ID的生成方式
一.程序直接生成: 使用jdk中的concurrent包可以轻松实现唯一数字型ID的生成,且无需考虑单例.采用高效率的CAS无需考虑synchronized关键字 import java.util.c ...
- valgrind 生成mysqld调用图之 select now()跟踪
1.mysqld起动方式: 1.mysqld以root用户运行 valgrind --tool=callgrind --separate-threads=yes --trace-children=y ...
- 如何选择一个 Linux Tracer (2015)
http://www.oschina.net/translate/choosing-a-linux-tracer
- Linux服务器的常用备份方法
系统备份是系统管理工作中十分重要的一个环切,本文详细介绍了各种Linux系统的备份方法,相信对大家的日常管理工作有所帮助. 备份是一项重要的工作,但是很多人没有去做.一旦由于使用不当造成数据丢失,备份 ...
- js调试技巧 Firefox调试技巧汇总
Firebug入门指南 : http://www.ruanyifeng.com/blog/2008/06/firebug_tutorial.html Firebug控制台详解: htt ...
- gvim设置字体和隐藏菜单栏工具栏
liunx下面设置字体 set guifont=Monaco\ 注意空格的位置,其他写法不认哦! Windows下面设置 set guifont=Monaco:h 隐藏菜单栏 set guioptio ...
- [wordpress]后台自定义菜单字段和使用wordpress color picker
Wordpress Version 4.4.2 参考链接 插件使用wordpress color picker:Add A New Color Picker To WordPress 后台菜单自定义字 ...
- zz存储系统中缓存的三种类型
三种基本类型的缓存:绕写式(write-around),直写式(write-through)和回写式(write-back). 绕写式(write-around)缓存意味着所有数据首先被写入到硬盘区, ...