[英]how call a TinyMCE plugin function?
how can I call a tinymce plugin function? 如何调用tinymce插件函数?
tinymce.activeEditor.plugins.customplugin.customfunction(customvar);
not working! 不工作!
tinymce.activeEditor.plugins.customplugin.customfunction(customvar); tinymce.activeEditor.plugins.customplugin.customfunction(customvar);
is the correct way to call such a function. 是调用这样一个函数的正确方法。 Be aware that tinymce.activeEditor
needs to be set already in order to use it. 请注意,需要设置tinymce.activeEditor
才能使用它。 tinymce.activeEditor
gets set when the user clicks into the editor for example. tinymce.activeEditor
,当用户点击编辑器时,会设置tinymce.activeEditor
。 Otherwise use 否则使用
tinymce.get('your_editor_id_here').plugins.customplugin.customfunction(customvar);
There might be another reason for your function call not to work: The function you want to call needs to be defined like the functions getInfo
, _save
and _nodeChange
in the save plugin (see the developer build of tinymce to inspect this plugin in the plugins directory). 您的函数调用可能还有另一个原因:要调用的函数需要像保存插件中的函数getInfo
, _save
和_nodeChange
一样定义(请参阅开发人员构建的tinymce来检查插件目录中的这个插件)。
The save plugin shortened here: 保存插件缩短了:
(function() {
tinymce.create('tinymce.plugins.Save', {
init : function(ed, url) {
...
},
getInfo : function() {
...
},
// Private methods
_nodeChange : function(ed, cm, n) {
...
},
// Private methods
...
_save : function() {
}
});
// Register plugin
tinymce.PluginManager.add('save', tinymce.plugins.Save);
})();
You may call the getInfo
function of this plugin using the following javascript call: 您可以使用以下javascript调用调用此插件的getInfo
函数:
tinymce.get('your_editor_id_here').plugins.save.getInfo();
Put the function you want to expose to the outside world in self
. 把你希望暴露给外界的功能self
。
tinymce.PluginManager.add('myplugin', function(editor) {
var self = this;
var self.myFunction = myFunction(); // Put function into self!
function myFunction() {
console.log('Hello world!');
}
}
Then: 然后:
tinymce.get('your_editor_id_here').plugins.myplugin.myFunction();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.