Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click event on TinyMCE 4.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?

like image 260
Scipius2012 Avatar asked May 02 '13 07:05

Scipius2012


1 Answers

TinyMCE v4 has changed things from v3 - try:

setup : function(ed) {
    ed.on("click", function() {
        alert("Editor Clicked!  Element: " + this.target.nodeName);
    });
};
like image 113
Alex McMillan Avatar answered Nov 18 '22 06:11

Alex McMillan