Ramesh
Ramesh

Reputation: 1083

How to use click events in CKEditor..?

I am writing an small code to run on CKEditor document click event, but its not working. My code is,

var element = CKEDITOR.document.getById( 'Editor_TextArea' );
element.on( 'click', function( ev )
{
//mycode
   alert('ok');
  }
  );

Can anyone help me..

Upvotes: 5

Views: 17364

Answers (3)

Ozesh
Ozesh

Reputation: 6964

editor.editable().on('click', function (event) {
    //YOUR CODE GOES HERE 
});

Upvotes: 1

jaydip jadhav
jaydip jadhav

Reputation: 487

This will work emailTemplateBody is name of textarea field.

var editor = CKEDITOR.instances.emailTemplateBody

editor.on('contentDom', function () {

    var editable = editor.editable();

    editable.attachListener(editable, 'click', function () {
        console.log("click event");
    });
});

Upvotes: 4

Ramesh
Ramesh

Reputation: 1083

That CKEDITOR.document.getById( 'Editor_TextArea' ); is not giving any values for me.. So i used the below code and its works well.

CKEDITOR.instances['Editor_TextArea'].on('contentDom', function() {
    this.document.on('click', function(event){
         //your code
         alert('Click Event');
     });
});

Upvotes: 14

Related Questions