I have the following viewModel
var viewModel = new myViewModel([{
Name: "Name",
price: 32,
tax: 22,
}, {
Name: "Name",
price: 32,
tax: 22,
}]);
I have a data-bind to
<tbody data-bind='foreach: personInfo'>
and input:
<td>
<input class='required' data-bind='value: Name'/>
</td>
<td>
<input class='required' data-bind='value: Price'/>
</td>
<td>
<input class='required' data-bind='value: Tax'/>
</td>
and I want to get the computed value for price and then for tax however I am not successful. :(
self.totalSurcharge = ko.computed(function () {
var total = 0;
for (var i = 0; self.PersonInfo().length; i++)
total += self.PersonInfo[i].price;
return total;
});
any idea?
UPDATE:
something like this: http://jsfiddle.net/hamsaya/9XNDH/1/
Thanks