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

setting viewmodel's object property

1 Answer 62 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Ahmet
Top achievements
Rank 1
Ahmet asked on 05 Sep 2012, 06:52 AM
I have two separate js files. one contains a kendo observable object. when I set viewmodel's object property from another js file, the object is set but object's properties are still undefined.

<script type="text/javascript">
    var previewModel = kendo.observable({
        question: {}
    });
    kendo.bind($("#preview-question"), previewModel);
</script>
<div id="preview-question">
    <div data-bind="text: question.QuestionText"></div>
</div>

another-js-file.js
previewModel.set("question", ko.toJSON(self.question()));

this code sets the question object but its properties still undefined.

1 Answer, 1 is accepted

Sort by
0
Ahmet
Top achievements
Rank 1
answered on 05 Sep 2012, 10:26 AM
solved the problem 
in the setting part it should be set to an object not json string.
Tags
MVVM
Asked by
Ahmet
Top achievements
Rank 1
Answers by
Ahmet
Top achievements
Rank 1
Share this question
or