javascript 如何在 CKEditor 中使用点击事件..?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11721022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:07:07  来源:igfitidea点击:

How to use click events in CKEditor..?

javascriptclickckeditor

提问by Ramesh

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

我正在编写一个小代码来在 CKEditor 文档单击事件上运行,但它不起作用。我的代码是,

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

Can anyone help me..

谁能帮我..

回答by Ramesh

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

CKEDITOR.document.getById( 'Editor_TextArea' );对我没有任何价值..所以我使用了下面的代码并且它运行良好。

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

回答by jaydip jadhav

This will work emailTemplateBodyis name of textareafield.

这将起作用的emailTemplateBodytextarea字段名称。

var editor = CKEDITOR.instances.emailTemplateBody

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

    var editable = editor.editable();

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

回答by Ozesh

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