javascript - Listen to click events inside CKEditor dialog - Stack Overflow

admin2025-04-20  0

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!

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!

Share Improve this question asked Jul 24, 2013 at 11:54 Ahmed ChergaouiAhmed Chergaoui 1032 silver badges6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745128206a286552.html

最新回复(0)