Question

I have an editor that built as follows:

        EditorBuilder builder = context.Html.Telerik().Editor()
                                                      .Name(ID)
                                                      .Encode(false)
                                                      .HtmlAttributes(new { style = string.Format("width:100%;height:{0}px", height) })
                                                      .Value(HttpUtility.HtmlEncode(value));

        return builder.ToHtmlString();

Everything works as expected. What I want to do now, is get the contents of the editor to allow the user to "preview" it in another window. After some searching, I came across $find(<%=RadEditor.ClientID%>);, but I am not using this form of generating the editor (and it's in razor).

So, my question is, how do I get at the contents of the editor using jQuery? val() does not work.

Thanks in advance!

Was it helpful?

Solution

Telerik stores the content of the editor using the jQuery data() method. To access the content of the editor use the following code:

var editor = $("#<your editor ID goes here>").data("tEditor");
alert(editor.value());

The ID passed to jQuery must match the ID you passed to the Html.Telerik().Editor().Name() function.

The code above only works if you have setup the necessary scripts for the telerik editor.

For more information please see the telerik client side api documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top