admin管理员组文章数量:1420073
OK. i know may be this question has been asked before :
Here
But my question is that how can i call a plugin function from outside button not from toolbar button.
I have added a custom plugins:
tinymce.PluginManager.add('example', function(e) {
function customfunction(){
e.focus(true);
alert('Hello TinyMce');
}
}
);
Check this on Fiddle
and i am calling this customfunction
from other function which is called when i click on Custom Button
.
Like this:
function clickme()
{
tinymce.get('textareaid').plugins.example.customfunction();
}
Button:
<button onclick="clickme()" >Custom Button</button>
But it is not working for me?
Am i doing right thing by calling custom plugin function
with that way?
Am i missing anything?
OK. i know may be this question has been asked before :
Here
But my question is that how can i call a plugin function from outside button not from toolbar button.
I have added a custom plugins:
tinymce.PluginManager.add('example', function(e) {
function customfunction(){
e.focus(true);
alert('Hello TinyMce');
}
}
);
Check this on Fiddle
and i am calling this customfunction
from other function which is called when i click on Custom Button
.
Like this:
function clickme()
{
tinymce.get('textareaid').plugins.example.customfunction();
}
Button:
<button onclick="clickme()" >Custom Button</button>
But it is not working for me?
Am i doing right thing by calling custom plugin function
with that way?
Am i missing anything?
Share Improve this question edited May 23, 2017 at 12:17 CommunityBot 11 silver badge asked May 25, 2014 at 9:57 Shail ParasShail Paras 1,1632 gold badges14 silver badges35 bronze badges2 Answers
Reset to default 3One possibility would be to add a button with a unique ID
to the toolbar and call the click event of the button. The plugin would look like this:
tinymce.PluginManager.add('example', function(e) {
function customfunction() {
e.focus(true);
alert('Hello TinyMce');
}
e.addButton('testButton', {
id: "testButton",
text: 'Example',
icon: false,
onclick: function() {
// calls the custom function
customfunction();
}
});
}
);
Then initialise the tinymce editor like this:
tinymce.init({
selector: "textarea",
plugins: "example",
// show the button
toolbar: "testButton undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
Finally call the button click event:
function clickme()
{
document.getElementById("testButton").click();
}
Don't use the add_filter
. The plete code form your tinymce fiddle:
<script type="text/javascript">
tinymce.PluginManager.add('example', function(e) {
function customfunction() {
e.focus(true);
alert('Hello TinyMce');
}
e.addButton('testButton', {
id: "testButton",
text: 'Example',
icon: false,
onclick: function() {
customfunction();
}
});
}
);
tinymce.init({
selector: "textarea",
plugins: "example",
toolbar: "testButton undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
//add_filter('mce_external_plugins', 'example');
function clickme()
{
document.getElementById("testButton").click();
}
</script>
<form method="post" action="">
<textarea name="content" id="textareaid"></textarea>
</form>
<button onclick="clickme();" >abc</button>
your function is stored in
tinymce.PluginManager.items[0]
inspecting the dom you can see that function. try to alert it
版权声明:本文标题:javascript - tinymce - Is it possible to call a custom plugin function from outside the toolbar? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745331550a2653835.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论