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

Disable Radeditor using javascript on client side

3 Answers 579 Views
Let's talk about telerik (the good and the bad)
This is a migrated thread and some comments may be shown as answers.
Creztor
Top achievements
Rank 1
Creztor asked on 27 Jun 2010, 08:45 AM
Not sure if this is the correct forum or if this can be done, but is there anyway the radeditor can be disabled using javascript on the client side?  I am having problems with a website I visit that uses a radeditor and wondering if I can disable it using a javascript command?  I know of other editors (such as tinyMCE) and curious if I can do the same for Radeditor if a site is having problems?  Obviously I am not a programmer but appreciate any info if this can or can't be done.

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 30 Jun 2010, 09:22 AM
Hello Creztor,

You can disable RadEditor on the client using the 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>

This method will disable the content area typing and the toolbar, but the editor will be rendered on the page and its client-side API will be fully functional.

You can also disable RadEditor from the server by setting the Enabled property of the editor to false. When the Enabled property is set to false, RadEditor is rendered as a simple DIV element on the page, containing the value of its Html property. The RadEditor object is missing and it is not possible to use the RadEditor's Client-Side API, its client event handlers and methods.

Best 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
0
Mohammad Bazlamit
Top achievements
Rank 1
answered on 21 Sep 2010, 09:10 AM
Thanks Rumen  for the help,

 I tried your solution but I had a problem which is after disabling and enabling the radeditor for 2 or 3 times, the control goes disabled even I call the following 

editor.enableEditing(true);
editor.set_editable(true);

Any Idea to solve this problem 

I'm using version 2010.1.309.35 

Thank you in advance,
M. Bazlamit
0
Mohammad Bazlamit
Top achievements
Rank 1
answered on 21 Sep 2010, 09:30 AM
Hi again,

I solved the problem, the problem was I calling twice the following
editor.enableEditing(false);

which was cause the problem.

Best regards,
M Bazlamit.
Tags
Let's talk about telerik (the good and the bad)
Asked by
Creztor
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Mohammad Bazlamit
Top achievements
Rank 1
Share this question
or