2012-02-09 10 views
2

私はJavascriptの専門家ではないので、なぜこの小さなボタンプラグインがCleditorで想定されていることをしているのか混乱していますが、jqueryエディタでエラー警告がポップアップします。ここでCleditor - マイナープラグインエラー

はコードです:

(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の経験が不足しているため、私が行方不明になっていることは確かです。

答えて

3

エラーがここにある事前に

おかげで、あなたは

editor.execCommand(data.command, html); 

を持っており、それは以下のようになります。

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

EDIT:迷惑

verry、あなたの関数の終わりに追加する:

return false; 

は、ここで私は戻ってではなく、エラーのポップアップがまだ私に同じメッセージを与えていることを加えたこと

と最終的なコード

(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); 
+0

ためjsfiddleです。 – MadScientist

関連する問題