my viewmodel has two arrays (simplified version)
array_a = ko.observableArray(["a", "b", "c"]);
array_b = ko.observableArray(["Foo", "Bar", "Bash"]);
I want to iterate over one while binding to the value of another so I have this
<ul data-bind="foreach: array_a">
<li><input data-bind="value: array_b()[$index()]" type="text"></li>
</ul
this shows the value but doesn’t seem to update it when the input text is changed??
If you want to have update-able values in your
array_byou need to wrap the values into observables (because ko bindings are one way if the binding source is not anko.observable).So this should work:
Se in action in this
JsFiddle.