jquerymobile在打开另一个对话框后关闭对话框
在ABC页面上,我首先弹出一个jQueryMobilejquerymobile在打开另一个对话框后关闭对话框,jquery,cordova,jquery-mobile,modal-dialog,Jquery,Cordova,Jquery Mobile,Modal Dialog,在ABC页面上,我首先弹出一个jQueryMobile对话框 此对话框有一个按钮,用于调用第二个对话框: <a href="/second" data-role="button" data-rel="dialog">Second dialog</a> 我想点击这个按钮,结果如下: 第一个对话框关闭 弹出第二个对话框 当我关闭第二个对话框时,剩下的是ABC页 然而,发生的情况是: 弹出第二个对话框 当我关闭第二个对话框时,剩下的是第一个对话框 现在我必须关闭第一
对话框
此对话框有一个按钮,用于调用第二个对话框:
<a href="/second" data-role="button" data-rel="dialog">Second dialog</a>
我想点击这个按钮,结果如下:
第一个
对话框关闭
- 弹出第二个
对话框
- 弹出第二个对话框
- 当我关闭第二个对话框时,剩下的是第一个对话框
- 现在我必须关闭第一个对话框,该对话框位于ABC页面左侧
第一个
对话框时,如何从第一个
对话框调用第二个
对话框
<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>
$(函数(){
$(“#链接2”)。在(“单击”上,函数(事件,用户界面){
$(“dialog1”).dialog(“关闭”);
}
});
测试
对话1
对话2
尝试代码。然后让我知道这是否有效。打开第二个弹出窗口时设置一个短时间间隔
$('#Popup1').dialog('close');
setTimeout(function () {
$.mobile.changePage('#Popup2', {
'role': 'dialog'
});
}, 1000);
这里的主要问题是“打开”和“关闭”对话框用词不当。你并不是真的“打开”或“关闭”它们,而是使用浏览器历史记录“导航到”或“导航离开”——你要么将对话框作为页面添加到历史记录中,要么将其删除(返回)。当从第一个对话框导航到另一个对话框时,它会将第二个对话框推到浏览器历史记录上,但会使用关闭动画设置第一个对话框的动画 一旦你了解了这一点,找到一个解决方案就变得相当容易了,你可以使用几个选项