[英]How to configure TinyMCE editor event to be fired only once?
I have a requirement to fire the ' SetContent ' event only once. 我要求只触发一次' SetContent '事件。 I've tried
我试过了
var ed = tinymce.get("editor");
ed.on('SetContent', function(e) {
// Turns off event so that it doesn't fire again
ed.off('SetContent');
// Performs the task that need to be performed once
});
ed.setContent('some content');
I'm using TinyMCE Version: 4.9.2-120 我正在使用TinyMCE版本:4.9.2-120
The above code raises a JavaScript error and doesn't work. 上面的代码引发了JavaScript错误,无法正常工作。
There's a link on TinyMCE website that says it is feasible http://archive.tinymce.com/wiki.php/api4:method.tinymce.off.static TinyMCE网站上有一个链接,说这是可行的http://archive.tinymce.com/wiki.php/api4:method.tinymce.off.static
Can someone guide me through? 有人可以引导我通过吗?
Thank you. 谢谢。
Hi I've solved the issue. 嗨,我已经解决了这个问题。
Basically, there's a function that allows you to run an event only once. 基本上,有一个功能允许您只运行一次事件。 Use that like this:
像这样使用:
var ed = tinymce.get("editor");
ed.once('SetContent', function(e) {
// Performs the task that need to be performed once
});
ed.setContent('some content');
I hope this will be of some help to someone. 我希望这会对某人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.