javascript TinyMCE 4.0 上的点击事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16332292/
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
Click event on TinyMCE 4.0
提问by Scipius2012
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 4.0 集成到我的 Web 应用程序中。我想在单击 textarea 时放置一个单击事件,但它不起作用。我查看了官方文档,并尝试了以下代码:
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 is undefined”。
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?
你对如何做到这一点有什么想法吗?
回答by Alex McMillan
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);
});
};
回答by Thariama
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);
});
});
}