Listen to click events inside CKEditor dialog

吃可爱长大的小学妹 提交于 2019-12-12 19:40:15

问题


I have a ckeditor instance, to which I added a custom dialog box using:

CKEDITOR.dialog.add('quicklinkDialog', function(editor) {
   return {
     title: 'Quick Links',
     minWidth: 400,
     minHeight: 200,

     contents: [
       {
        id: 'tab1',
        label: 'Add a quick link',
        elements: [
        {
         type: 'html',
         html: '<p>This is some text and then: <a href="">Click me!</a></p>'
        }]
   };
 });

I want to add a "click" event listener on the link inside my dialog box. When that link is clicked, content will be inserted into my textrea (the dialog box will also be closed).

Anyone knows how I might do this? Thanks in advance!


回答1:


Here you go:

{
    type: 'html',
    html: '<p>This is some text and then: <a href="">Click me!</a></p>',
    onLoad: function( a ) {
        CKEDITOR.document.getById( this.domId ).on( 'click', function() {
            var dialog = this.getDialog();
            dialog.hide();
            dialog._.editor.insertHtml( this.html );
        }, this );
    }
}

See the API to know more.



来源:https://stackoverflow.com/questions/17833291/listen-to-click-events-inside-ckeditor-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!