I have this template
<!--ko template: { name: 'multiCheckBtn', data: { elems: posGenders, compareWith: gender, switch: switchCheckBtn} }-->
<!--/ko-->
<script id="multiCheckBtn" type="text/html">
<span class="fakeCheck" data-bind="foreach: { data: $data.elems, as: 't' } ">
// here $data becomes alias to t and I don't how to access other params, like $data.switch
<span class="btn" data-bind="text: t, css: { selected: t == $data.compareWith() }, click: $data.switch } "></span>
</span>
</script>
What I want is inside foreach to get access to compareWith and switch variables passed to template originally, but I only can access them before foreach. Inside loop $data variable becomes alias to t, and I can’t access other variables.
Is there a way how I can pass the data to foreach loop, so that I could access it like I’m trying to access in ?
You can access them using
$parentobject:Here is working fiddle: http://jsfiddle.net/vyshniakov/nVsgK/