HTML5与JQuery.Mobile(五)
来源:互联网 发布:人人店分销系统源码 编辑:程序博客网 时间:2024/05/04 05:12
本节主要讲述JQuery Mobile的API。
API的官方文档参见http://jquerymobile.com/demos/1.1.1/ 。
当jQuery Mobile启动时,将会对document对象自动触发mobileinit事件,所以如果我们需要覆盖某些默认设置,我们就需要绑定mobileinit事件处理:
$(document).bind("mobileinit", function(){ //apply overrides here});
因为mobileinit事件立即触发,所以你需要在jQuery Mobile加载之前绑定处理函数,那么对于JavaScript文件的链接顺序是这样:
<script src="jquery.js"></script><script src="custom-scripting.js"></script><script src="jquery-mobile.js"></script>
可以使用jQuery的$.extend来覆盖默认设置:
$(document).bind("mobileinit", function(){ $.extend( $.mobile , { foo: bar });});
或者,你也可以这样设置属性:
$(document).bind("mobileinit", function(){ $.mobile.foo = bar;});
至于$.mobile对象的属性设置,具体参见文档。
对于事件的处理:
- 使用$(document).bind('pageinit'), 而不是$(document).ready()。这是因为页面中可能有多个page(因为jQuery Mobile中大量使用了Ajax技术),如果使用ready那么只有对第一个page有效;
- $(document).bind('pagecreate') 和 $(document).bind('pageinit')。当前推荐使用pageinit替代pagecreate来操作一些页面显示之前的增强标记;
- jQuery Mobile支持很多的触屏事件:tap、taphold、swipe、swipeleft、swiperight;
- jQuery Mobile支持很多的鼠标事件:vmouseover、vmouseout。。。
- 支持屏幕旋转事件;
- 支持滚动事件;
- 支持页面加载事件;
- 页面改变、切换、移除事件;
- 布局事件;
- 动画事件;
方法和工具:
- $.mobile.changePage;
- $.mobile.loadPage;
- $.fn.jqmData(), $.fn.jqmRemoveData();
- $.fn.jqmEnhanceable();
- $.fn.jqmHijackable();
- $.mobile.showPageLoadingMsg;
- $.mobile.hidePageLoadingMsg;
- $.mobile.fixedToolbars.show;
- $.mobile.fixedToolbars.hide;
- $.mobile.path.parseUrl;
- $.mobile.path.makePathAbsolute;
- $.mobile.path.makeUrlAbsolute;
- $.mobile.path.isSameDomain;
- $.mobile.path.isRelativeUrl;
- $.mobile.path.isAbsoluteUrl;
- $.mobile.path.get;
- $.mobile.base;
- $.mobile.silentScroll;
- $.mobile.activePage;
以上内容基本上可以通过字面意思理解,当然最重要的还是例子;
通过data-role和input的type属性还能设置一些控件的表现形式;
同样还可以对theme进行设置,可以使用我们之前提到的themeroller。
- HTML5与JQuery.Mobile(五)
- 使用 jQuery Mobile 与 HTML5 开发 Web App(五) —— jQuery Mobile 表单下
- HTML5与JQuery.Mobile(一)
- HTML5与JQuery.Mobile(二)
- HTML5与JQuery.Mobile(三)
- HTML5与JQuery.Mobile(四)
- HTML5与JQuery.Mobile(六)
- 使用 jQuery Mobile 与 HTML5 开发 Web App(十四) —— jQuery Mobile 方法上
- 使用 jQuery Mobile 与 HTML5 开发 Web App(十三) —— jQuery Mobile 方法下
- 使用 jQuery Mobile 与 HTML5 开发 Web App(十一) —— jQuery Mobile 事件详解
- 使用 jQuery Mobile 与 HTML5 开发 Web App(二) —— jQuery Mobile 基础
- 使用 jQuery Mobile 与 HTML5 开发 Web App(三)—— jQuery Mobile 按钮
- 使用 jQuery Mobile 与 HTML5 开发 Web App(四) —— jQuery Mobile 表单上
- 使用 jQuery Mobile 与 HTML5 开发 Web App(六) —— jQuery Mobile 内容格式
- 使用 jQuery Mobile 与 HTML5 开发 Web App(七) —— jQuery Mobile 列表
- 使用 jQuery Mobile 与 HTML5 开发 Web App(八) —— jQuery Mobile 工具栏
- 使用 jQuery Mobile 与 HTML5 开发 Web App(十五) —— jQuery Mobile 与响应式
- 使用 jQuery Mobile 与 HTML5 开发 Web App(十二) —— jQuery Mobile 页面事件与 deferred
- AForge.NET 如何使用 Histogram 功能
- yii 登录表单
- Flat-field correction
- C#小练习(使用方法重载使得方法可以分别计算整数、双精度、字符串)
- C#小练习(猜数字)
- HTML5与JQuery.Mobile(五)
- DSP小记
- Linux 性能监控分析
- 影像處理之空間及頻率定義域
- 非迴旋濾波器
- 迴旋濾波器(convolution filter)
- 位移及相位邊緣強化
- 305. No cross, no crown. 不经历风雨,怎么见彩虹
- 線段強化(Line segment enhancement)