I have the following ViewModel:
function vm(model) {
var self = this;
var Create = function (data) {
var order = ko.utils.extend(data, {});
order.Price = ko.observable(data.Price);
return order;
}
self.orders = ko.mapping.fromJS(model, {
create: function (options) {
return Create(options.data);
}
});
self.FirstPrice = ko.pureComputed(function () {
return parseFloat(self.orders()[0].Price());
});
}
When the page is loaded the "FirstPrice" is updated normally, but after change the Price on first row of "orders" array, the "FirstPrice" remains the first value after page load.
What is missing?
* I removed some lines of code to simplify the example
Thanks
self.orders
needs to be an observable array. – mrtig