jQuery移动更改页面 [英] Jquery mobile change page

查看:86
本文介绍了jQuery移动更改页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该网站的网页有两列布局, http://jquerymobile.com/demos/1.0.1/

I have two column layout for a webpage from the site, http://jquerymobile.com/demos/1.0.1/

现在,他们已经使用以下方法为changePage提供了规定 <a href="#xxx" data-role="button">Sample</a>

Now they have provided provisions to changePage using <a href="#xxx" data-role="button">Sample</a>

但是我的问题是如何使用代码以编程方式更改页面.

But my question is how to programmatically change page using code.

$.mobile.changePage("#xxx");不适用于我

推荐答案

这是一个真正的简单示例: http://jsfiddle.net/shanabus/YjsPD/

Here is a real simple example for you: http://jsfiddle.net/shanabus/YjsPD/

$.mobile.changePage("#page2");

文档: http://api.jquerymobile.com/jQuery.mobile.changePage/

其他示例:

//transition to the "about us" page with a slideup transition
$.mobile.changePage( "about/us.html", { transition: "slideup"} );

//transition to the "search results" page, using data from a form with an ID of "search""   
$.mobile.changePage( "searchresults.php", {
    type: "post",
    data: $("form#search").serialize()
});

//transition to the "confirm" page with a "pop" transition without tracking it in history   
$.mobile.changePage( "../alerts/confirm.html", {
    transition: "pop",
    reverse: false,
    changeHash: false
});

更新

正如Chase Roberts在下面的评论中指出的,此changePage方法在1.4版中已弃用.这是新的 pagecontainer更改事件的文档.

As Chase Roberts points out in the comments below, this changePage method was deprecated in version 1.4. Here is the documentation for the new pagecontainer change event.

示例:

$.mobile.pageContainer.pagecontainer("change", "#page", { options });

这个SO问题也得到解决:

This was also addressed on this SO question: How to change page in jQuery mobile (1.4 beta)?

这篇关于jQuery移动更改页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆