CKEditor关闭对话框

时间:2010-08-10 14:40:51

标签: ckeditor

我正在尝试从我的自定义插件调用CKEditor对话框的close函数。就像当你点击“smileys”插件中的微笑时发生的那样,但我无法找到我如何在自己的插件中做同样的事情。 谢谢回复!

我有解决方案。 在我的插件中,我需要在“onLoad”部分中调用“CKEDITOR.dialog.add”中的close函数。所以,我必须这样做:

CKEDITOR.dialog.add( 'plugin_name', function( editor ){
    onLoad: function( event ){
        [...some code...]
        event.sender.hide();
    }
}

2 个答案:

答案 0 :(得分:21)

CKEDITOR.dialog.getCurrent().hide()

答案 1 :(得分:2)

我建议你在内部使用CKEditor Dialog插件完成它。见plugin.js

中的第535行

单击按钮或触发取消事件,确保插件正确处理。

代码示例:

// If there's a Cancel button, click it, else just fire the cancel event and hide the dialog.
        button = CKEDITOR.dialog.getCurrent().getButton( 'cancel' );
        if ( button )
            CKEDITOR.tools.setTimeout( button.click, 0, button );
        else {
            if ( CKEDITOR.dialog.getCurrent().fire( 'cancel', { hide : true } ).hide !== false )
            CKEDITOR.dialog.getCurrent().hide();
        }