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

$find('RadEditor1').set_html("hello") doesn't work.

1 Answer 44 Views
Window
This is a migrated thread and some comments may be shown as answers.
Daniel Qin
Top achievements
Rank 1
Daniel Qin asked on 07 Oct 2010, 02:56 PM
Hello

i am using RadEditor(it's DNNRichTextEditor really) inside RadWindow. 
such like :
<telerik:RadWindow ID="WinAddNew" runat="server">
    <ContentTemplate>
         <cc1:DNNRichTextEditControl ID="txtContent" runat="server" Width="500" Height="300" />
    </ContentTemplate>
</telerik:RadWindow>


var editor;

        function pageLoad()  
        {  
            editor = $find("<%=txtContent.ClientID%>"); //get a reference to RadEditor client-side object   
        }
editor is null. 
even i am using $get. 
could you give me some advices?

Thank you.
Daniel

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Oct 2010, 02:10 PM
Hello Daniel,

You can try the following code to get a reference to RadEditor

<script type="text/javascript">
 
    function pageLoad() {
        if (typeof ($telerik) != "undefined") {
            if ($telerik.radControls && Telerik.Web.UI.RadEditor) {
                for (var i = 0; i < $telerik.radControls.length; i++) {
                    var control = $telerik.radControls[i];
                    if (Telerik.Web.UI.RadEditor.isInstanceOfType(control)) {
                        //control is a radeditor object
                        control.set_html("<b>hello<b>");
                    }
                }
            }
        }
    }
</script>


The code should be run after our controls have been initialized (after the Sys.Application.Init event). The code I have pasted includes some extra checks to make sure it does not fail if there is no RadEditor on the page. To check the type of the control I use the isInstanceOfType method. See this article for more information: How-to create a javascript array of all particular RadControls on the page.

Another approach is to attach the OnClientLoad event to get a reference to RadEditor. See this KB article for more information: Executing custom code called on RadEditor's events.

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
Tags
Window
Asked by
Daniel Qin
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or