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 ...
随机推荐
- Webx学习(一)
什么是webx Webx3_Guide_Book中是这样介绍的: Webx是一套基于Java Servlet API的通用Web框架. Webx致力于提供一套极具扩展性的机制.来满足Web应用不断变化 ...
- redis实现spring-redis-data的入门实例
redis的客户端实现.主要分为spring-redis-data .jredis. 记录下spring-redis-data的学习心得:spring-redis-data 中我目前主要用了它的存.取 ...
- java_Cookies_1_商品浏览历史记录servlet2
public class CookiesServlet2 extends HttpServlet { // 显示商品详细信息 public void doGet(HttpServletRequest ...
- scrollLeft、offsetLeft、clientLeft、clientHeight详解
offsetLeft:Html元素相对于自己的offsetParent元素的位置 scrollLeft:返回和设置当前横向滚动务的坐标值 scrollLeft.offsetLeft.clientLef ...
- 聊一聊ES5数组(Array)新增的那些方法
一.前言 ES5中新增的一些处理数组(Array)的方法, 对于用JavaScript处理数据非常有用.我总结了一下,给这些方法分了类,大体如下: 2个索引方法:indexOf() 和 lastInd ...
- 【转】Android开发之Bitmap的内存优化详解
本文来源:转载自: http://mobile.51cto.com/abased-410796.htm 在Android应用里,最耗费内存的就是图片资源.而且在Android系统中,读取位图Bitma ...
- Lucene全文检索系列(一)
1. Lucene简介 Lucene是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎.Lucene以其方便使用.快速实施以及灵活性受到广泛的关注.它可以方便地嵌入到各种应用中实现针对应用的全文 ...
- linux语言环境设置
查看linux的支持的语言集合 执行locale命令 LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_CTYPE="zh_CN.UTF-8" LC_NU ...
- [转载]删除所有的.svn文件夹
Windows 下,在DOS窗口中运行如下命令 dos 代码 for /r <你项目的路径> %i in (.svn) do rd /s /q %i Linux 下,可以先运行 显示出当前 ...
- js Date.UTC() 与 php strtotime()生成的时间截不一样
Difference in UTC date between PHP and Javascript 工作中,因使用highcharts显示数据,需要将PHP 将日期转换为UTC 时区的时间截,然后通过 ...