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

[Solved] Calling filters as required from JavaScript.

2 Answers 127 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Frank Witte
Top achievements
Rank 1
Frank Witte asked on 28 May 2009, 05:46 AM

How can I allow-disallow certain filters (including custom filter) to work or not to work while getting HTML content and design content?

Basically while doing get_html to get html for saving I want to execute following filter

1.      My Custom Filter1

2.      OptimizeSpans

3.      ConvertToXhtml

4.      IECleanAnchors

And while switching to html mode by my custom tool using set_mode command I want to execute only IndentHTMLContent filter.

 

How can I achieve this? Is there any way to execute the filters, changes the sequence in which filter executes and all from JavaScript?

 

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 01 Jun 2009, 11:03 AM
Hello Frank,

I just answered your identical support ticket on the subject. Please, do not post identical questions in the forums and in the ticketing system.

The code below demonstrates how to get a reference to a client-side content filter of RadEditor, disable it before getting the content via the editor.get_html(true) method and enable the filter after that:

<telerik:RadEditor ID="RadEditor1" runat="server"
    <Content><i>test</i><br /><i>test</i></Content> 
</telerik:RadEditor> 
<input type="button" value="Get Content" onclick="GetHtmlContent()" /> 
<script type="text/javascript"
function GetHtmlContent() 
   var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object 
   var filter = editor._filtersManager.getFilterByName("IndentHTMLContentFilter"
   filter.Enabled = false
   var content = editor.get_html(true);  
   filter.Enabled = true
   alert(content);  
</script> 


Best wishes,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rumen
Telerik team
answered on 02 Jun 2009, 10:56 AM
Hi Frank,

Please, replace the Enabled property with set_enabled(true|false), because the Enabled property is used for backward compatibility with the classic RadEditor. In ASP.NET AJAX the specification requires to use getters and setters methods instead of properties, e.g.

<telerik:RadEditor ID="RadEditor1" runat="server">  
    <Content><i>test</i><br /><i>test</i></Content>  
</telerik:RadEditor>  
<input type="button" value="Get Content" onclick="GetHtmlContent()" />  
<script type="text/javascript">  
function GetHtmlContent()  
{  
   var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object  
   var filter = editor._filtersManager.getFilterByName("IndentHTMLContentFilter")  
   filter.set_enabled(false);  
   var content = editor.get_html(true);   
   filter.set_enabled(true);  
   alert(content);   
}  
</script>  

Greetings,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Frank Witte
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or