简体   繁体   English

点击TinyMCE 4.0上的活动

[英]Click event on TinyMCE 4.0

Recently I tried to integrate TinyMce 4.0 in my web application. 最近我尝试在我的Web应用程序中集成TinyMce 4.0。 I want to put a click event for when I click on the textarea but it doesn't work. 我想点击textarea时点击事件,但它不起作用。 I have looked on the official documentation, and I've tried the following code: 我查看了官方文档,我尝试了以下代码:

tinyMCE.init({
   ...
   setup : function(ed) {
      ed.onClick.add(function(ed, e) {
          console.debug('Editor was clicked: ' + e.target.nodeName);
      });
   }

There are an error that appear : "TypeError: ed.onClick is undefined". 出现错误:“TypeError:ed.onClick未定义”。

So, I have tried to put directly a onclick event on the iframe but it's a failure : 所以,我试图直接在iframe上放一个onclick事件,但这是一个失败:

$("iframe").contents().bind('click', function(){
...
});

Do you have any ideas on how to do this? 你有什么想法怎么做?

TinyMCE v4 has changed things from v3 - try: TinyMCE v4改变了v3的东西 - 尝试:

setup : function(ed) {
    ed.on("click", function() {
        alert("Editor Clicked!  Element: " + this.target.nodeName);
    });
};

Hmm, you could try 嗯,你可以试试

$(ed.getDoc()).bind('click', function(){
...
});

Update: Looks like there is no editor initialized to that point of time. 更新:看起来没有编辑器初始化到那个时间点。 Try 尝试

   setup : function(ed) {
      ed.onInit.add(function(ed, e) {
        ed.onClick.add(function(ed, e) {
          console.debug('Editor was clicked: ' + e.target.nodeName);
        });
      });
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM