以下 jQuery 插件有一个 API,您可以在其中添加自己的方法。
这里是 a simple example .
在该页面的示例中,我将如何调用函数 your_method
?
他们不显示这个。我只想在页面上放置一个按钮,然后在单击该按钮时触发我自己的自定义方法。
最佳答案
这对我有用:
if (!RedactorPlugins) var RedactorPlugins = {};
RedactorPlugins.myPlugin = function() {
return {
init: function() {
},
myMethod: function() {
alert ("method");
}
};
};
$("#redactor").redactor({
plugins: ['myPlugin']
});
$("#redactor").redactor("myPlugin.myMethod");
或者你可以将它添加到其他东西的点击事件中
$(".selector").on("click", function(e) {
$("#redactor").redactor("myPlugin.myMethod");
});
关于javascript - 如何在 Redactor 插件中触发自定义方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14164940/