我试图在 jQuery UI 模式对话框中获取一个按钮来关闭自身并打开另一个模式对话框。
问题是,打开的第二个对话框将始终打开,而不会出现您期望从模式对话框中看到的屏幕覆盖,因此您仍然可以单击模式后面的屏幕。
jQuery如下
$(function () {
$("#DialogSelectEventType").dialog({
modal: true,
autoOpen: true,
width: 400
});
$("#DialogCreateToDo").dialog({
model: true,
autoOpen: false,
width: 450
});
$("#btnCreateToDo").click(function (e) {
$("#DialogSelectEventType").dialog({ close: function (e, ui) {
$("#DialogCreateToDo").dialog("open");
}}).dialog("close");
});
});
我还尝试将处理程序更改为
$("#btnCreateToDo").click(function (e) {
$("#DialogSelectEventType").dialog("close");
$("#DialogCreateToDo").dialog("open");
});
这没有帮助
这是jsFiddle
有人可以帮我理解为什么会发生这种情况吗?这是一个错误还是我做错了什么?
最佳答案
您的代码中有一个拼写错误,在第二个对话框定义中您有“model : true”,而它应该是“modal : true”
$(function () {
$("#DialogSelectEventType").dialog({
modal: true,
autoOpen: true,
width: 400
});
$("#DialogCreateToDo").dialog({
modal: true,
autoOpen: false,
width: 450
});
$("#btnCreateToDo").click(function (e) {
$("#DialogSelectEventType").dialog({ close: function (e, ui) {
$("#DialogCreateToDo").dialog("open");
}}).dialog("close");
});
});
试试这个:http://jsfiddle.net/tzKf7/3/
希望有帮助。
关于javascript - jQuery 无法正确打开 2 个连续的模式对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16802619/