I have a viewmodel like
AppViewModel = {
agent : ko.observableArray([ {
name : 'test',
age : '23'
}])
};
My json data comes like
{"agent":[{"name":"john","age":"23"},{"name":"conor","age":"23"}]}
for ajaxcall evry 3 sec
How to replace the view model with new data
I tried
success : function(responseData) {
var data = ko.toJS(responseData);
//AppViewModel.agent.push(data);
AppViewModel.agent.replace(agent,data);
}
but doest work.
push()is for arrays, it adds a new items to the array.