【发布时间】:2014-04-13 16:05:33
【问题描述】:
我的 jquery 对话框关闭时出现以下错误。 jQuery 1.9.1 jquery-ui-1.10.3
错误:无法在初始化之前调用对话框上的方法;试图调用方法'close'
// 检查给定的回调是否在列表中。
var popupDialog = $("<div id='popupDialogBox'></div>");
function Popup(url, width, height) {
if (width == undefined)
width = 400;
if (height == undefined)
height = 300;
//var buttonArray = {};
//buttonArray["Close"] = function () {
// $(popupDialog).dialog("close");
//};
popupDialog.dialog({
closeOnEscape: false,
modal: true,
autoOpen: false,
resizable: false,
buttons: [{
text: "Cancel",
click: function () {
$(popupDialog).dialog("close");
}
}]
//buttons: buttonArray,
//buttons: {
// "OK": function () {
// //debugger;
// //alert('test');
// //$(popupDialog).parent().remove();
// $(this).dialog("close");
// return false;
// }
//}
//buttons: [{
// text: "close",
// "class": "button",
// close: function () {
// $(popupDialog).dialog('close');
// //alert('test');
// }
//}]
});
popupDialog.load(url + '?popup=1');
popupDialog.dialog("option", "width", width);
popupDialog.dialog("option", "height", height);
popupDialog.dialog('open');
return false;
}
如果我在 $(popupDialog).dialog('close') 之前放置警报,则警报有效,但对话框仍然给出相同的错误
不确定我在这里做错了什么,但似乎没有任何效果。
有什么想法吗?
【问题讨论】:
标签: javascript jquery jquery-ui-dialog