How to change pages in jQuery Mobile? [duplicate]

柔情痞子 提交于 2020-01-11 12:42:32

问题


my code is like this :

<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>

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>

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.

That's how i move,

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

回答1:


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,{});


来源:https://stackoverflow.com/questions/43242743/how-to-change-pages-in-jquery-mobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!