开发者

CKEditor close dialog

I'm trying to call close function for CKEditor dialog box from my custom plugin. Just like it happens when you are clicking on smile in "smileys" plugin, but I can't find out how can I do the same in my own plugin. Thanx for reply!

I've got the solution. In my plugin I needed to call close function from "CKEDITOR.dialog.add" in "onLoad" section. So, I have to do this:

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


CKEDITOR.dialog.getCurrent().hide()


I propose you do it the same way it is done by CKEditor Dialog plugin internally. See line 535 in plugin.js

By clicking the button or firing the cancel event you ensure correct handling by the plugin.

Code sample:

// 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();
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜