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
2 Answers
Reset to default 13TinyMCE 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);
});
});
}