jQuery mobile类库使用时加载导航历史的方法简介
作者:bea
jQuery.mobile.navigate( url [, data ] ) 改变URL和跟踪历史。作品为浏览器和无历史新的API url:是必须的参数。类型:字符串 data:是可选的参数。类型:对象。 更改哈希片段两次然后日志提供导航事件数据时,浏览器向后移动的历史 // Starting at http://example.com/// Alter the URL: http://example.com/ => http://example.c
jQuery.mobile.navigate( url [, data ] )
改变URL和跟踪历史。作品为浏览器和无历史新的API
url:是必须的参数。类型:字符串
data:是可选的参数。类型:对象。
更改哈希片段两次然后日志提供导航事件数据时,浏览器向后移动的历史
// Starting at http://example.com/
// Alter the URL: http://example.com/ => http://example.com/#foo
$.mobile.navigate( "#foo", { info: "info about the #foo hash" });
// Alter the URL: http://example.com/#foo => http://example.com/#bar
$.mobile.navigate( "#bar" );
// Bind to the navigate event
$( window ).on( "navigate", function( event, data ) {
console.log( data.state.info );
console.log( data.state.direction )
console.log( data.state.url )
console.log( data.state.hash )
});
// Alter the URL: http://example.com/#bar => http://example.com/#foo
window.history.back();
// From the `navigate` binding on the window, console output:
// => "info about the #foo hash"
// => "back"
// => "http://example.com/#bar
// => "#bar"
劫持一个链接点击使用导航方法,然后加载内容
// Starting at http://example.com/
// Define a click binding for all anchors in the page
$( "a" ).on( "click", function( event ) {
// Prevent the usual navigation behavior
event.preventDefault();
// Alter the url according to the anchor's href attribute, and
// store the data-foo attribute information with the url
$.mobile.navigate( this.attr( "href" ), { foo: this.attr( "data-foo" ) });
// Hypothetical content alteration based on the url. E.g, make
// an ajax request for JSON data and render a template into the page.
alterContent( this.attr( "href" ) );
});
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 基于jQuery 实现bootstrapValidator下的全局验证
- JavaScript的代码编写格式规范指南
- JSON遍历方式实例总结
- JS实现日期时间动态显示的方法
- 基于jQuey实现鼠标滑过变色(整行变色)
- js实现遍历含有input的table实例
- JavaScript中的return语句简单介绍
- 深入理解Java线程编程中的阻塞队列容器
- JS与jQuery遍历Table所有单元格内容的方法
- JavaScript的History API使搜索引擎抓取AJAX内容
- JavaScript给input的value赋值引发的关于基本类型值和引用类型值问题
- 小巧强大的jquery layer弹窗弹层插件
- 使用jQuery+EasyUI实现CheckBoxTree的级联选中特效
- win7下安装配置node.js+express开发环境
- 分享使用AngularJS创建应用的5个框架
- 如何利用AngularJS打造一款简单Web应用
- 使用CDN和AJAX加速WordPress中jQuery的加载
- 浅析jQuery移动开发中内联按钮和分组按钮的编写
- 使用jQuery在移动页面上添加按钮和给按钮添加图标