在ABC页面上,我弹出一个jQueryMobile first
对话框。
这个对话框有一个按钮,它调用第二个对话框:
<a href="/second" data-role="button" data-rel="dialog">Second dialog</a>
我想点击这个按钮,结果如下:
first
对话框已关闭second
对话框second
对话框时,会留下页ABC然而,所发生的情况是:
second
对话框second
对话框时,会留下first
对话框。first
对话框,使其与页ABC一起保留。jQueryMobile文档表示,当在对话框中单击任何链接时,框架将自动关闭对话框并转换到所请求的页面,就像对话框是普通页一样。
如何在关闭second
对话框时从first
对话框调用first
对话框?
发布于 2012-09-05 07:50:22
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<script>
$(function () {
$( "#link2" ).on( "click", function( event, ui ) {
$("dialog1").dialog('close');
}
});
</script>
</head>
<body>
<div data-role="page" id="example">
<div data-role="header">
<h1>test</h1>
</div>
<div data-role="content">
<a href="#dialog1" data-rel="dialog" id="link1">Open dialog1</a>
</div>
</div>
<div data-role="page" id="dialog1">
<div data-role="header">
<h1>dialog1</h1>
</div>
<div data-role="content">
<a href="#dialog2" data-rel="dialog" id="link2">Open dialog2</a>
</div>
</div>
<div data-role="page" id="dialog2">
<div data-role="header">
<h1>dialog2</h1>
</div>
<div data-role="content">
</div>
</div>
</body>
试试密码。让我知道这是否有效。
发布于 2013-09-20 16:42:28
打开第二个弹出窗口时,设置一个很短的时间间隔。
$('#Popup1').dialog('close');
setTimeout(function () {
$.mobile.changePage('#Popup2', {
'role': 'dialog'
});
}, 1000);
发布于 2013-09-20 17:07:15
这里的主要问题是“开始”和“结束”对话框是用词不当的。您并不是真正地“打开”或“关闭”它们,而是使用浏览器历史记录“导航到”或“导航离开”--您要么将对话框作为页面添加到历史记录中,要么删除它(“返回”)。当从第一个对话框导航到另一个对话框时,它会将第二个对话框推到浏览器历史记录上,但是用一个紧密的动画来动画第一个对话框。
一旦你意识到了这一点,找到一个解决方案就会变得非常容易,你可以使用几个选项。
https://stackoverflow.com/questions/12274992
复制相似问题