CKEditor's click event not firing

前端 未结 2 859
不思量自难忘°
不思量自难忘° 2020-12-21 16:09

I am using CKEditor 4.4.3 and trying to listen to an editor\'s click event:

editor.on(\'click\', function (e) {
      console.log(\'click event from attachin         


        
相关标签:
2条回答
  • 2020-12-21 16:46

    Correct way of attaching listeners to the editable element in CKEditor:

    editor.on( 'contentDom', function() {
        var editable = editor.editable();
        editable.attachListener( editable, 'click', function() {
            // ...
        } );
    } );
    

    Read more about the reasons why contentDom event has to be used instead of e.g. instanceReady in editable.attachListener documentation.

    0 讨论(0)
  • 2020-12-21 16:54

    Use attach the event handler to the editor's editable. This needs to be done after the editor is ready:

    editor.on('instanceReady', function (e) {
        editor.editable().on('click', function (event) {
            console.log('clicked');
        });
    });
    

    Fiddle: http://jsfiddle.net/8fZpz/

    0 讨论(0)
提交回复
热议问题