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

data-binding with knockout js

2 Answers 73 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gordon
Top achievements
Rank 1
Gordon asked on 24 Jan 2012, 05:45 AM
I saw another thread with some examples for using Knockout js to data-bind some Telerik controls, but I can't figure out how to use Knockout with a Telerik Editor control. Does anyone have any ideas?

2 Answers, 1 is accepted

Sort by
0
Accok5
Top achievements
Rank 2
answered on 01 Feb 2012, 10:54 PM
Did you find a solution? I'm also looking for this.

I found this link: http://www.telerik.com/community/forums/aspnet-mvc/grid/compatibility-with-knockout.aspx 
but that won't work for the editor.
0
Gordon
Top achievements
Rank 1
answered on 01 Feb 2012, 11:10 PM
That was the other thread I was referring to, actually.
I never actually got the data-binding to work at all, unfortunately. In my situation the data binding only needed to go one way: I edit in the editor and it updates other fields. In this situation I just wrote a client function for the editor's update event and updated the model that way. As below:
@(Html.Telerik().Editor()
        .Name("text")
        .ClientEvents(events => events
            .OnChange("TextOnChanged")
        )
)
 
<script type="text/javascript">
    function TextOnChanged() {
        var editor = $(this).data('tEditor');
        ViewModel.text(editor.value());
    }
</script>
Obviously, this does not suit all purposes, but it works for me. I'm still looking out for a better solution though.
Tags
Editor
Asked by
Gordon
Top achievements
Rank 1
Answers by
Accok5
Top achievements
Rank 2
Gordon
Top achievements
Rank 1
Share this question
or