Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ckeditor click event does not work

Tags:

ckeditor

I have a ckeditor plugin and inside the init: I want to capture the click event so I can do something.

CKEDITOR.plugins.add('Columns',{
  init : function(editor) {
    editor.on('doubleclick', function(ev) {console.log('hello');}); // Works
    editor.on('focus', function(ev) {console.log('hello');}); // Works

    editor.on('click', function(ev) {console.log('hello');}); // Does not work
    editor.on('mousedown', function(ev) {console.log('hello');}); // Does not work
  }
});

Any Ideas???

EDIT: OK could not get click working, I believe we need to create an event for that. However thanks to this post: http://alfonsoml.blogspot.com.au/2011/03/onchange-event-for-ckeditor.html

I managed to use 'saveSnapshot' which seems to fire each time I click so this now works

editor.on('saveSnapshot', function(ev) {console.log('hello');}); // Works
like image 661
Andre Avatar asked May 24 '12 05:05

Andre


1 Answers

I realise this is old but it doesn't have an answer to the original question.

CKEDITOR.plugins.add('Columns',{
    init : function(editor) {
        editor.on('instanceReady', function (e) {
            this.container.on('click', function (event) {
                console.log('hello');
            });
        });
    }
});

Note: this won't work when CKEditor is in 'classic iframe mode'. Instead, you'll need to use this.document (see: document property) to get a reference to the iframe.

like image 58
Red Taz Avatar answered Sep 22 '22 11:09

Red Taz