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

Rad editor enable/disable in javascript

5 Answers 458 Views
Editor
This is a migrated thread and some comments may be shown as answers.
vishesh kumar
Top achievements
Rank 1
vishesh kumar asked on 03 Mar 2010, 12:38 PM
hi,

I am using Rad controls of version 2009.02.0826.20 .
I need to enable/disable radeditor or make it editable  in javscript based on radio button click.

I went through few forums could not find the soln working.
editor is var by client id

editor.disabled=

false;  is not working out...

 



Please assist me.

Regards
Vishesh

5 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 03 Mar 2010, 12:52 PM
Hi Vishesh,

If you would like to disable the editor without hiding its tools, modules and content area then you should do that on the client using the editor.enableEditing(false) method. Here is an example:

<telerik:RadEditor runat="server" ID="RadEditor1">
    <Content>some test content</Content>
</telerik:RadEditor>
<input type="button" onclick="toggleEditing();return false;" value="Toggle editing" />
<script type="text/javascript">
var toggle = true;
function toggleEditing()
{
    var editor = $find("<%=RadEditor1.ClientID%>");
    toggle = !toggle;
    editor.enableEditing(toggle);
    editor.set_editable(toggle);
    if (toggle == false) editor.get_document().body.style.backgroundColor = "gray";
    else editor.get_document().body.style.backgroundColor = "";
}
</script>


Sincerely,
Rumen
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.
0
vishesh kumar
Top achievements
Rank 1
answered on 03 Mar 2010, 01:07 PM
Thanks for the response.
Microsoft JScript runtime error: Object doesn't support this property or method is the error I receive if i use

editor.enableEditing(

true); this like throws error

 

editor.set_editable(

true);

Please assist me

Vishesh

 

0
Rumen
Telerik team
answered on 03 Mar 2010, 01:22 PM
Hi Vishesh,

The solution works as expected with version 2009.02.826 of Telerik.Web.UI.dll.

For your convenience I have attached my test project. Are you able to reproduce the problem with it.


Greetings,
Rumen
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.
0
Phani
Top achievements
Rank 1
answered on 20 May 2010, 06:37 PM
Hello Friends,
Requirement: I have Template Manager with html templates, when i choose a template the editor should be readonly and the Template Manager tool bar should be enable which allows user to select another template.

This is my solution,

 
 <telerik:RadEditor runat="server" ID="ComposeEditor" Skin="WebBlue" ToolsFile="~/editor/BasicTools.xml" 
                Width="100%" Height="650px" EnableResize="False" EditModes="Design"
                OnClientCommandExecuted="OnClientCommandExecuted">  
                <CssFiles> 
                    <telerik:EditorCssFile Value="~/css/editorstyle.css" /> 
                </CssFiles> 
                <TemplateManager ViewPaths="~/templates" UploadPaths="~/templates" 
                    DeletePaths="~/templates" /> 
                <Content> 
                </Content> 
            </telerik:RadEditor> 

I place this below code in .aspx page. if i keep this in external js file, it gives me an error saying
"Microsoft JScript error: null" and pointing to enableEditing().

If you use this code in aspx file, always keep in RadCodeBlock.

function OnClientCommandExecuted(editor, args) {     
   // alert("Executed command was " + args.get_commandName());     
    if (args.get_commandName() == "TemplateManager") {     
        toggleEditing();     
    }     
}     
    
var toggle = true;     
function toggleEditing() {     
    var editor = $find("<%=ComposeEditor.ClientID%>");     
    toggle = !toggle;     
    editor.enableEditing(toggle);     
    editor.set_editable(toggle);     
    if (toggle == false) { editor.get_document().body.style.backgroundColor = "gray"; }     
    else { editor.get_document().body.style.backgroundColor = ""; }    
 
//Enabling the Template Manager tool in the editor.  
    var mode = editor.get_mode();   
    switch (mode) {   
    case 1:   
        var tool = editor.getToolByName("TemplateManager");   
        tool.setState(0);  
    break;   
    }  
}    
 


Hope this helps,
0
Rumen
Telerik team
answered on 24 May 2010, 03:09 PM
Hello Phani,

I am unable to reproduce this problem. For your convenience I have attached my project and video demonstrating my test, which you can see at: http://screencast.com/t/ZTUwMTNiM.

Regards,
Rumen
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
vishesh kumar
Top achievements
Rank 1
Answers by
Rumen
Telerik team
vishesh kumar
Top achievements
Rank 1
Phani
Top achievements
Rank 1
Share this question
or