javascript - How to know when observables in observableArray change (knockoutJS)? -
i have observablearray of info construction created, , in info structure, 1 of fields observable. how can maintain track of when values of inner observables (inside info structure) change? have tried subscribe inner variable, did not work.
i set fiddle mimic situation. consists of view model has ko.observablearray , , each item in array contains ko.observable properties. assuming have defined functions create objects in info structure, can place subscribe function within each of them.
here's link fiddle
the code:
function luggage(data) { var self = this; this.id = ko.observable(data.id); this.color = ko.observable(data.color); this.color.subscribe(function (newvalue) { console.log(self.id() + ' changed!'); }); } function vm() { this.train = ko.observablearray(): } javascript knockout.js knockout-2.0
No comments:
Post a Comment