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

Select editor in Jquery when using Html.Kendo().EditorFor

2 Answers 337 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 15 Mar 2013, 12:42 PM
I'm using the editor for a field that can be posted to the server.

                    @( Html.Kendo().EditorFor(model => model.TickerContent)
                           .Name("TickerContent")
                           .Encode(true)
                           .HtmlAttributes(new { style = "width:100%;height:440px" }))

On the same page as the form I have a list of items that I want to be able to edit, so I need to set the value of the editor. The demo code uses the following code to get and set the value of the editor:

<script>
    $(document).ready(function () {
        var editor = $("#Editor").data("kendoEditor");

        var setValue = function () {
            editor.value($("#value").val());
        };

        $("#get").click(function () {
            alert(editor.value());
        });

        $("#set").click(setValue);
    });
</script>

The value of variable editor is always undefined. My question is how can I get and set the editor value?

I tried var editor = $("#TickerContent").data("kendoEditor"); but the editor is still undefined.

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 19 Mar 2013, 09:47 AM
Hello Ryan,

The ID of the element is the same as the control Name so you should use "TickerContent" instead to find the object:

var editor = $("#TickerContent").data("kendoEditor");
Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ryan
Top achievements
Rank 1
answered on 23 Apr 2013, 11:06 AM
Thanks Daniel.
Tags
Editor
Asked by
Ryan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or