This is a migrated thread and some comments may be shown as answers.

Issue Adding Button in Sitecore 6.4

1 Answer 90 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 04 Jan 2012, 09:01 PM
Hello,

I am trying to add a button to a RadEditor in Sitecore 6.4 that will open up a dialog when clicked.  The button is displaying correctly, but I get an error when the button is clicked.  An alert pops up saying "The command EmbedBrightcoveVideo is not implemented yet."

I have added the following code to /sitecore/shell/Controls/Rich Text Editor/RichText Commands.js, which is what I thought was all I had to do to get it to work...


RadEditorCommandList["EmbedBrightcoveVideo"] = function(commandName, editor, tool) {
    alert('EmbedBrightcoveVideo fired.');
}


The JavaScript never fires.  I don't seem to be getting any JavaScript errors either.  Any ideas as to what could be wrong?

Thanks a lot.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Jan 2012, 02:21 PM
Hi,

Could you please tell exactly which version of RadEditor is used in SiteCore 6.4? RadEditor Classic (RadEditor.Net2.dll) or RadEditor for ASP.NET AJAX (Telerik.Web.UI.dll)?

If it is RadEditor Classic you should ensure that the script is imported after the editor's declaration, e.g.

<rad:RadEditor ID="RadEditor1" Runat="server" Width="600px" Height="500px" />
<script type="text/javascript" language="javascript">
RadEditorCommandList["Custom"] = function(commandName, editor, oTool)
                {
                    alert ("Custom command called");
                    /*TO DO: Implement something meaningful here*/
                };
</script>

as shown in the following demo: Adding Custom Tools. Note that RadEditor Classic does not support Firefox 6+ and will be rendered as a textarea in that browser.

If you use the new RadEditor for ASP.NET AJAX you see how to add a custom button in this demo: Custom Tools. Another option is to use the following code to execute a command of a custom button:

<telerik:RadEditor runat="server" ID="RadEditor1" OnClientCommandExecuting="OnClientCommandExecuting">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="EmbedBrightcoveVideo" Text="Embed Brightcove Video" />
        </telerik:EditorToolGroup>
    </Tools>
</telerik:RadEditor>
<script type="text/javascript">
    function OnClientCommandExecuting(editor, args) {
        //The command name   
        var commandName = args.get_commandName();
        if (commandName == "EmbedBrightcoveVideo") {
            alert('EmbedBrightcoveVideo fired.');
            args.set_cancel(true);
        }
    }
</script>



Greetings,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Editor
Asked by
Eric
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or