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

Enabling, disabling and applying content filters client-side via javascript

1 Answer 157 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Joseph Alfano
Top achievements
Rank 1
Joseph Alfano asked on 10 May 2010, 10:27 PM
How can I enable or disable content filters on the client-side via javascript and how can I apply an enabled filter to a particular radEditor using javascript?  

We have a page with many (>15) radEditors.  If we use the default behavior and apply content filters upon submit to insure that our output is XHTML compliant we observe a long delay before the page actually begins to submit. We have attempted to optimize this performance following the guidance provided on your site, but the performace is still not good enough.

What we would like to do is disable content filters in the ASPX markup by setting ContentFilters="None" so they will not be applied upon submit.  Then, whenever a user changes the mode of the radEditor from HTML to Design, or during other client-side events that we control, we would like to turn on the filters, apply them to the particular radEditor content, and then turn off the filters.  We have attempted to follow the suggestions in your forum (i.e. here and hereand have tried using the following code:

function radEditorControl_OnClientModeChange(editor, args) { 
    if (editor.get_mode() == 1) 
        ApplyFilters(editor); 
 
ApplyFilters = function(editor) { 
    //1. Enable filter 
    if (editor.get_filtersManager().getFilterByName("ConvertToXhtmlFilter") != null)  
        editor.get_filtersManager().getFilterByName("ConvertToXhtmlFilter").Enabled = true 
    else 
        Telerik.Web.UI.Editor["ConvertToXhtmlFilter"].Enabled = true
         
    //2. Apply filter 
    editor.set_html(editor.get_html(true)); 
      
    //3. Disable filter 
    if (editor.get_filtersManager().getFilterByName("ConvertToXhtmlFilter") != null)  
        editor.get_filtersManager().getFilterByName("ConvertToXhtmlFilter").Enabled = false
    else 
        Telerik.Web.UI.Editor["ConvertToXhtmlFilter"].Enabled = false

I have tried this with a variety of client-side filters (StripScriptsFilter, FixUlBoldItalic, FixEnclosingP, MozEmStrongFilter, ConvertFontToSpanFilter, ConvertToXhtmlFilter).  In all cases the javascript code executes fine, but the radEditor content is not modified by the filter.

Do you have any guidance for me?  Thanks so much for the help!

Joe

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 12 May 2010, 04:34 PM
Hi Joseph,

The reason why the newly enabled content filters are not applied is because OnClientModeChange event is raised after the editor mode is changed and the content filters are applied. Unfortunately, RadEditor does not offer any suitable event to handle the required functionality. However, could you please check this KB article I believe it is useful for such scenarios.

Kind regards,
Dobromir
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Editor
Asked by
Joseph Alfano
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or