最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Click event on TinyMCE 4.0 - Stack Overflow

programmeradmin4浏览0评论

Recently I tried to integrate TinyMce 4.0 in my web application. I want to put a click event for when I click on the textarea but it doesn't work. 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".

So, I have tried to put directly a onclick event on the iframe but it's a failure :

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

Do you have any ideas on how to do this?

Recently I tried to integrate TinyMce 4.0 in my web application. I want to put a click event for when I click on the textarea but it doesn't work. 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".

So, I have tried to put directly a onclick event on the iframe but it's a failure :

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

Do you have any ideas on how to do this?

Share Improve this question edited Jul 16, 2015 at 19:40 mbarkhau 8,4695 gold badges33 silver badges35 bronze badges asked May 2, 2013 at 7:08 Scipius2012Scipius2012 8051 gold badge10 silver badges21 bronze badges 2
  • Where are you test(browser)? – Amit Commented May 2, 2013 at 7:09
  • Hi, I've tested on the last version of Google Chrome and the last version of Firefox. – Scipius2012 Commented May 2, 2013 at 7:19
Add a ment  | 

2 Answers 2

Reset to default 13

TinyMCE v4 has changed things from v3 - try:

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);
        });
      });
   }
发布评论

评论列表(0)

  1. 暂无评论