views:

332

answers:

1

I don't have access to the actual asp.net server tag itself, so I need to change the StripFormattingOnPaste property to the EditorStripFormattingOptions enum with JavaScript and I'm not sure how. I have some code that adds an OnClientLoad() and OnClientCommandExecuted() functions that works so I can add it in there, I'm just not sure where the property exists on the client-side and what the enum value would be:

// init OnClientLoad and OnClientCommandExecuted event handlers for all radeditors on the page
Sys.Application.add_load(function() {
    if (typeof ($telerik) != "undefined") {
        if ($telerik.radControls && Telerik.Web.UI.RadEditor) {
            for (var i = 0, l = $telerik.radControls.length; i < l; i++) {
                var control = $telerik.radControls[i];
                if (Telerik.Web.UI.RadEditor.isInstanceOfType(control)) {
                    var editor = control;

                    // ??? editor._stripFormattingOptions = Telerik.Web.UI.StripFormattingOptions.NoneSupressCleanMessage

                    // editor already loaded, fire event
                    OnClientLoad(editor);
                    // attach event handler for paste commands
                    editor.add_commandExecuted(function(ed, args) {
                        return OnClientCommandExecuted(ed, args);
                    });
                }
            }
        }
    }
});

Update: I've discovered that the correct enum setting that I want is Telerik.Web.UI.StripFormattingOptions.NoneSupressCleanMessage.

Update #2: I see that the RadEditor JS object has a _stripFormattingOptions property, but I think it might just be for private use.

+1  A: 

The Telerik controls are based on ASP.NET AJAX and use pretty much the same coding conventions - public properties have getters and setters methods. In this case you should use

editor.set_stripFormattingOptions(Telerik.Web.UI.StripFormattingOptions.NoneSupressCleanMessage);

To get the current value, use

var value = editor.get_stripFormattingOptions();

The property you saw (editor._stripFormattingOptions) is just used to store the value. Since its name starts with an underscore you are correct to assume that it is private and so you should not rely on it. The getter and setter methods are public and you are free to use them.

lingvomir
Awesome, thanks for the info!
travis