Replace Observablearray With New Data
I have a viewmodel like AppViewModel = { agent : ko.observableArray([ { name : 'test', age : '23' }]) }; My json data comes like
Solution 1:
All you have to do is set the observable
success : function(responseData) {
var data = ko.toJS(responseData);
AppViewModel.agent(data.agent);
}
Solution 2:
You can just assign new data to array:
success : function(responseData) {
var data = ko.toJS(responseData);
AppViewModel.agent(data);
}
Post a Comment for "Replace Observablearray With New Data"