【发布时间】:2012-05-31 22:00:05
【问题描述】:
我现在面临一个问题。我有一个包含对象列表的可观察数组。每当我更新数组的任何对象的属性时。它不会反映在浏览器上。我已经使用了所有的淘汰功能,如替换、删除.但是更新来自可观察数组而不是浏览器。
这是我的问题的一个示例:
var ViewModel=new {
self=this;
self.List=ko.observableArray([]);
}
$(function(){
ko.applyBinding(ViewModel);
})
$.post('/url',{},function(data){
ViewModel.List(data); //data is list having 4 property having CommentList as again object-->id,title,description,CommentList--->commenttitle,commentdescription
})
//During change of property of commentList
$.post('/updateComment',{},function(obj){//Here obj-->obj.Commenttitle="some title",obj.commentdescription='some description'
//Let say there require update 4th object of List and 2nd property of CommentList
ViewModel.AnswerList()[4].CommentList.splice(2,1,obj);
})
//But nothing updation on browser
【问题讨论】:
-
请考虑将您的帖子编辑为精确的语言,并使用一些最少的代码来解决您的问题
标签: knockout.js