javascript - Get an item from another array with the same index in knockout -
the situation is: have 2 tables same amount of rows , columns (for explanation phone call them table1 , table2).
basically have show values table1 beside value same row , column in table2. eg:
table1:
1 | 2 3 | 4
table2:
5 [1: value comes same row , column table1] | 6 [2] 7 [3] | 8[4]
now, have matrix (an array, arrays) next construction in knockout:
var vm = header([{ lots: [1, 2], otherlots: [3, 4] }, { lots: [5, 6], otherlots: [7, 8] }]);
and apply model bindings see in this fiddle.
the problem, $parent.lots[$index].count
doesn't homecoming expected. tried ko.computed
, didn't work.
also values ko.observable
when modify in table1, alter should reflected in table2
is there workaround requirement work?
it seems aren't calling underlying observables. see fork of fiddle.
http://jsfiddle.net/cellenburg/kwh2v/1/
<p data-bind="text: $parent.lots()[$index()] ? $parent.lots()[$index()].count : ('nothing show @ index ' + $index())" />
i changed previous line phone call observable $index()
, lots()
.
hope helps.
javascript knockout.js
No comments:
Post a Comment