Cleditor - 小插件错误
我不是 Javascript 专家,所以我有点困惑为什么这个小按钮插件在 Cleditor 中执行它应该执行的操作,但 jquery 编辑器会弹出错误警告。
这是代码:
(function($) {
// Define the hello button
$.cleditor.buttons.video = {
name: "video",
image: "video.gif",
title: "Insert Video",
command: "inserthtml",
buttonClick: videoClick
};
// Add the button to the default controls before the bold button
$.cleditor.defaultOptions.controls = $.cleditor.defaultOptions.controls
.replace("bold", "video bold");
// Handle the hello button click event
function videoClick(e, data) {
// Get the editor
var editor = data.editor;
// Insert some html into the document
var html = "[VIDEO]";
editor.execCommand(data.command, html, null, data.button);
// Hide the popup and set focus back to the editor
// editor.focus();
}
})(jQuery);
这是一个简单的插件,当您单击按钮时,会将 [VIDEO] 插入文档中。
问题是,由于某种原因,在插入文本后,
在插件按钮下的一个黄色小窗口中会出现“执行 inserthtml 命令时出错”。
我确信由于缺乏 Javascript 经验,我错过了一些小事情。
提前致谢
I am not a Javascript specialist so I am a little confused as to why this little button plugin does what it is supposed to in Cleditor but a error warning is popped up by the jquery editor.
Here is the code:
(function($) {
// Define the hello button
$.cleditor.buttons.video = {
name: "video",
image: "video.gif",
title: "Insert Video",
command: "inserthtml",
buttonClick: videoClick
};
// Add the button to the default controls before the bold button
$.cleditor.defaultOptions.controls = $.cleditor.defaultOptions.controls
.replace("bold", "video bold");
// Handle the hello button click event
function videoClick(e, data) {
// Get the editor
var editor = data.editor;
// Insert some html into the document
var html = "[VIDEO]";
editor.execCommand(data.command, html, null, data.button);
// Hide the popup and set focus back to the editor
// editor.focus();
}
})(jQuery);
It is a simple plugin that inserts [VIDEO] into the document when you click the button.
The problem is that for some reason after it inserts the text this comes up
"Error Executing the inserthtml command" In a little yellow window under the plugin button.
I am sure it is something small that I am missing due to lack of experience with Javascript.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误就在这里
,它应该是:
编辑:
非常烦人,在函数末尾只需添加:
这里是 jsfiddle 为
最终代码
Error is here you have
and it should be:
EDIT:
verry annoying, at the end of your function just add:
here is jsfiddle for that
and final code