【发布时间】:2011-11-16 14:27:50
【问题描述】:
我正在设计一个 JQuery Mobile 应用程序并在那里遇到一个问题,
我有两个页面,page1.aspx 和page2.aspx,我必须从page1 重定向到page2。目前我正在使用window.location.href 进行重定向,但它也在地址栏中显示加载。
为了避免这种情况,我想使用$.mobile.changePage。
问题:
现在在重定向之前,我在localStorage 变量中设置一个值,基于page2.aspx 的加载事件的这个值我必须绑定页面。它与window.location.href 一起工作正常,但在使用$.mobile.changePage 时,它正在重定向,但如果我刷新它正在加载的页面,在到达page2.aspx 后加载事件不会触发。
所以我的问题是在显示 page2.aspx 加载事件时必须触发。
谁能告诉我为什么 page2.aspx 在使用 $.mobile.changePage 时没有加载?
如果有人知道解决办法,请尽快回复,非常紧急。
提前致谢。
Page1.aspx:
localStorage.setItem("pageCode", "NULLException");
//$.mobile.changePage("../MessageDialog.aspx", "slide", true, true);
$.mobile.changePage("../MessageDialog.aspx", { transition: "slide", changeHash: true, reverse: false });
Page2.aspx:
$('div').live("pageshow", function () {
if (localStorage.getItem("pageCode") != null) {
if (localStorage.getItem("pageCode") == "NullException") {
$('#lblDialogHeader').text("Error");
$('#lblDialogMessage').text("Sorry");
document.getElementById("btnOK").setAttribute("onclick", 'Test()');
}
}
}
HTML
<div data-theme="c" data-role="page" id="test">
<div data-role="header" data-theme="b">
<h1><label id="lblStatus">Status</label></h1>
</div>
<div data-role="content" data-theme="b">
<h3><label id="lblDialogHeader"></label></h3>
<p><label id="lblDialogMessage"></label></p>
</div>
<div data-role="footer" data-theme="b">
<div data-role="navbar">
<ul>
<a href="#" data-role="button" id="btnOK" data-icon="check">OK</a>
<a href="#" data-role="button" id="btnCancel" data-rel="back" data-icon="delete" >Cancel</a>
</ul>
</div>
</div>
</div>
【问题讨论】:
-
unable to load dynamic listview in jquery mobile 的可能重复项——我今天刚刚回答了同样的问题
标签: jquery jquery-mobile