1、错误描述
jquery.min.js:2 Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'
angular.min.js:107 Error: cannot call methods on dialog prior to initialization; attempted to call method 'open'
2、错误原因
var dialog = $( "#dialog" ).dialog({
resizable: false,
height: "auto",
400,
modal: true,
buttons: {
"保存": function() {
dialog.dialog( "close" );
},
"取消": function() {
$( this ).dialog( "close" );
}
}
});
在保存按钮函数中,之前用的是$(this).dialog("close"); 但是发现点击按钮无效,于是在弹窗前加了var dialog=,然后直接用dialog.dialog("close"); 再次尝试,发现有效果但是会提示错误描述中的错误3、解决办法
保证弹窗实例化在前,调用close方法在后