I have observableArray
with elements (elements are not observables, but some unobservable objects). I have also computed
variable that depands on observableArray
. If I push elements into array, then everything works (I mean - computed variable is recalculated).
However, if I change some properties of observableArray single items, then computed is not recalculated:
var myObsArr = ko.observableArray();
// myObsArr is loaded using ko.mapping.fromJS with data from server
// but I am using custom mapping that won't create observables for observableArray items, part of my custom mapping (the one that corresponds to observable item) is something like this:
create: function (options) {
// here are some manipulations and
return ko.toJS(options.data); //doesn't create observables for observableArry items
}
var computedArr = ko.computed(function() {
var t = self.myObsArr();
// do manipulations on t and return manipulated array
});
// later I need to change some elements of observable array, for example:
myObsArr[0].Month = "Mar"; //doesn't trigger computed to be recalculated
How to trigger computed to be recalculated when any object inside observable array is changed?