1
votes

Does anyone have idea, if it's possible to detect whenever a change occur inside observableArray while using ko mapping, this mean without having to create the model by hand?

self.items = ko.observableArray([])
var data = ko.mapping.fromJS(result)
self.items.push(data);

I would like to log any changes occurred in any property inside my array of objects.

Thanks

2

2 Answers

3
votes

If I'm not mistaken, you should be able to use subscribe on the observable to get that information.

See the bottom of this page for more info:

Explicitly subscribing to observables

-3
votes
self.items = ko.observableArray([])   
self.item.subscribe(function(context){  
//Comment if there is any changes in the observable array this function will get trigger and changed date ma get in context   

});