如何在jQuery Mobile中更改页面? [英] How to change pages in jQuery Mobile?

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

问题描述

我的代码是这样的:

<div data-role="page" id="LoginPage">

    <div data-role="header">

    </div>

    <div data-role="main" class="ui-content">
    <input type="button" value="התחבר" onclick="checkDetails()" />
    </div>

    <div data-role="footer">

    </div>
</div>

现在,通过功能checkDetail(),我需要移至上一页(下)

now, by the function checkDetail() i need to move to anthor page(below)

<div data-role="page" id="HomePage">

    <div data-role="header">
        <h3>asd</h3>
    </div>

    <div data-role="content" class="ui-content">

    </div>

    <div data-role="footer">
        <ul>
            <li><a>a</a></li>
            <li><a>as</a></li>
            <li><a>asd</a></li>
        </ul>
    </div>
</div>

问题是当我移到它时,我到达HomePage,但它显示为普通的html页面而不是jquery移动设备. 顺便说一句,LoginPage显示为jQueryMobile,但HomePage没有显示.

the problem is when i move to it, i reach to HomePage but it shown as a normal html page not a jquery mobile. By the way, LoginPage shown as jQueryMobile, but HomePage isn't.

这就是我的动向

$('#LoginPage').hide(function () {
    $('#HomePage').show();
});

推荐答案

您不应使用核心jQuery库中的$.show()$.hide()方法进行页面导航. jQuery Mobile中的页面导航通过 Pagecontainer Widget 处理-专门使用change方法.

You should not use the $.show() and $.hide() methods from the core jQuery library for page navigation. Page navigation in jQuery Mobile is handled through the Pagecontainer Widget -- specifically using change method.

在您的示例中,您将执行以下操作:

In your example, you would do the following:

var homePage = $("#HomePage");
$.mobile.pageContainer.pagecontainer("change",homePage,{});

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

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