如何在jQuery Mobile中更改页面? [英] How to change pages in 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屋!