我想关闭第一个按钮的 onclick 函数中的对话框,我尝试运行我通过 console.log 在 windowManager 对象上找到的 close() 函数,但它不起作用。当我做:
console.log(editor.windowManager);
我看到以下输出:
Object {windows: Array[1], open: function, alert: function, confirm: function, close: function}
然后我调用你在上面的输出中看到的关闭函数,就像这样
editor.windowManager.close();
然后我得到:
Uncaught TypeError: Cannot call method 'close' of undefined
这是我的代码
tinymce.PluginManager.add('jbimages', function (editor, url) {
function jbBox() {
editor.windowManager.open({
title: 'Upload an image',
file: url + '/dialog-v4.htm',
width: 350,
height: 135,
buttons: [{
text: 'Upload',
classes: 'widget btn primary first abs-layout-item',
disabled: false,
onclick: function(){
$('#mce_39-body iframe').contents().find('#upl').submit();
editor.windowManager.close();
}
}, {
text: 'Close',
onclick: 'close'
}]
})
}
});