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

Very strange problem with custom tag

1 Answer 34 Views
Editor
This is a migrated thread and some comments may be shown as answers.
ericc34
Top achievements
Rank 1
ericc34 asked on 19 May 2011, 02:10 PM
In radEditor I have a custon button to set teg at begin en end of my selection like this :

Telerik.Web.UI.Editor.CommandList[

 

"Schedule"] = function (commandName, editor, args) {

 

 

 

 

var selection = editor.getSelectionHtml();

 

 

 

 

//Remove all custom tags before insert new custom tags

 

 

 

var html = editor.get_html(true).replace("<ordredujour>", "");

 

 

html.replace(

 

"</ordredujour>", "");

 

 

 

 

var newhtml = html.replace(selection, '<ordredujour>' + selection + '</ordredujour>');

 

 

editor.set_html(newhtml);

 

 

 

}

I must remove old tag if old tag exist because i want only one <ordredujour> tag in all my html

My problem is that in HTML tab, I don't see my custom tag around selection. Do you know why ?

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 24 May 2011, 09:49 AM
Hi ericc34,

I found a mistake in your code and it is that you should assign a variable the value returned by the highlighted line:

html = html.replace("</ordredujour>", "");


In addition the custom tags in IE should have a namespace, e.g.<my:ordredujour> in other case the browser will modify them.

Here is the rewritten code that works on my side:

<telerik:RadEditor ID="RadEditor1" runat="server">
    <Tools>
        <telerik:EditorToolGroup>
            <telerik:EditorTool Name="Schedule" />
        </telerik:EditorToolGroup>
    </Tools>
</telerik:RadEditor>
<script type="text/javascript">
Telerik.Web.UI.Editor.CommandList[ "Schedule"] = function (commandName, editor, args)
{
    var selection = editor.getSelectionHtml(); //Remove all custom tags before insert new custom tags
    var html = editor.get_html(true).replace("<my:ordredujour>", "");
    html = html.replace("</my:ordredujour>", "");
    var newhtml = html.replace(selection, '<my:ordredujour>' + selection + '</my:ordredujour>');
    editor.set_html(newhtml);
}
</script>


All the best,
Rumen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Editor
Asked by
ericc34
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or