I have a view model with an observableArray
(named 'all') of objects. One of the properties of that object is an observable
name selected. I want some code to execute whenever the selected property of the of the child object in the array changes. I tried manually subscribing to all
via all.subscribe()
but that code only fires when items are added or removed. I updated the code to do it like this:
all.subscribe(function () {
ko.utils.arrayForEach(all(), function (item) {
item.selected.subscribe(function () {
//code to fire when selected changes
});
});
});
Is this the right way to do this or is there a better way?