由于某些超出我的原因,更改视图模型时我的视图没有更新。我在这里做错了什么?
它显示:
Test1 100
Test2 200
当我期望:
Test1 300
Test2 400
Javascript:
var testModel = kendo.data.Model.define({
fields: {
"Name": {
type: "text"
},
"Amount": {
type: "number"
}
}
});
testViewModel = new kendo.observable({
Data: [
new testModel({ "Name": "Test1", "Amount": 100 }),
new testModel({ "Name": "Test2", "Amount": 200 })
]
});
kendo.bind("#test", testViewModel.Data);
var data = testViewModel.Data;
data[0].Amount = 300;
data[1].Amount = 400;
testViewModel.set("Data", data);
HTML:
<div id="test" data-bind="source: Data" data-template="testTemplate"></div>
<script id="testTemplate" type="text/x-kendo-template">
<div>
<span data-bind="text: Name"></span>
<span data-bind="text: Amount"></span>
</div>
</script>