Here is a jsFiddle demonstrating the following problem:
Given a foreach binding over a list of (observable) strings, the observables do not seem to update from changes to input tags bound inside the foreach. One would expect them to. Here's the example from the jsFiddle:
HTML
<ul data-bind='foreach: list'>
<li><input data-bind='value: $data'/></li>
</ul>
<ul data-bind='foreach: list'>
<li><span data-bind='text: $data'></span></li>
</ul>
Javascript
var vm = { list: [ko.observable('123'), ko.observable('456')] };
ko.applyBindings(vm);
In the above example, one would expect that updating the input tags in the first list would cause the observables to update. Unfortunately they do not update as expected, as can be seen by the failure of the second list to reflect any changes to made to the first.
I verified that the list was not in fact being updated when the input elements are changed.
Interestingly, changes made to the observables are reflected in both lists (as one would expect). Namely, vm.list[1]("444")
will update the second element of both lists.
My recollection is that Knockout 2.0.0 did not have this issue, though I stand to be corrected. I did not find any documentation, Google or comments in the Knockout code that yielded any indication as to why this does not work or how to achieve the outcome expected.
Why does this not work as expected, and are there any workarounds that do not require changing the data structure?