I have a list of items and each item consists of a number of text fields. The text fields need to be observables with an event handler on them such that if the user changes an entry, the event handler is called and actioned accordingly.
Here's the array declaration:
self.items = ko.observableArray(ko.utils.arrayMap(items, function(item) {
return { quantity: item.quantity, size: item.size };
}));
...and there's a textbox for the total quantity. Basically, on editing the quantity in the rows of the array, I need the textbox to display the running total:
Total: input data-bind='value: total'
I've created a JSFiddle here:
http://jsfiddle.net/phykell/HyYFq/
The idea is that if the user enters/changes a quantity in one of the items, the sum-totals are updated for the given size and the resulting TOTAL value will be updated.
Any advice welcome - should I be trying to use the method described here:
http://knockoutjs.com/documentation/unobtrusive-event-handling.html
Thanks for looking :)