1

我想关闭第一个按钮的 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'
                        }]
                    })
                }
  });
4

1 回答 1

0

您可以像这样关闭弹出窗口:

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: editor.windowManager.close()
      }]
    })
  }
});

查看提供的插件,它分配editor.dom给 var 并在其上调用 close 的更常见方式,如下所示:

var win = editor.dom
...
win.close()
于 2014-04-29T01:57:13.710 回答