Cleditor-次要插件错误 [英] Cleditor - minor plugin error

查看:88
本文介绍了Cleditor-次要插件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是Java语言专家,所以我对于为什么这个小按钮插件能够实现Cleditor中应有的功能感到困惑,但是jquery编辑器会弹出错误警告.

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.

这是代码:

(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]插入文档中.

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

在执行inserthtml命令时出错",位于黄色黄色的窗口中,位于插件按钮下.

"Error Executing the inserthtml command" In a little yellow window under the plugin button.

我敢肯定,由于缺乏Java脚本的经验,我错过了一些小东西.

I am sure it is something small that I am missing due to lack of experience with Javascript.

预先感谢

推荐答案

错误在这里

editor.execCommand(data.command, html);

,它应该是:

editor.execCommand(data.command, html, null, data.button);

非常烦人,在函数末尾只需添加:

verry annoying, at the end of your function just add:

return false;

这是 jsfiddle

和最终代码

(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();
       return false;
  }


})(jQuery);

这篇关于Cleditor-次要插件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆