Note that there are some explanatory texts on larger screens.

plurals
  1. PONested, containerless foreach in KnockoutJS
    text
    copied!<p>I am having problems using containerless foreach nested inside a normal foreach binding within a table. The solution of adding your own <code>&lt;tbody&gt;</code> <a href="https://stackoverflow.com/questions/8115896/knockout-js-containerless-foreach-not-working-with-table?lq=1">found here</a> does not work as seen in this <a href="http://jsfiddle.net/ZLXJm/2/" rel="nofollow noreferrer">jsFiddle</a>.</p> <p>HTML</p> <pre><code>&lt;table style="border: solid 1px black;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;!-- ko foreach: data --&gt; &lt;th data-bind="text: $data.name"&gt;&lt;/th&gt; &lt;!-- /ko --&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody data-bind="foreach: names"&gt; &lt;tr&gt; &lt;td data-bind="text: $data.name"&gt;&lt;/td&gt; &lt;!-- ko foreach: data --&gt; &lt;td data-bind="text: $data.abbr"&gt;&lt;/td&gt; &lt;!-- /ko --&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>JS</p> <pre><code>var data = { names: [ { name: 'Rick' }, { name: 'Bob'}, { name: 'Sue' }, ], data:[ { name: 'object1', abbr: 'obj1' }, { name: 'object2', abbr: 'obj2' }, { name: 'object3', abbr: 'obj3' }, { name: 'object4', abbr: 'obj4' } ] }; var model = function( data ){ this.names = ko.observableArray( data.names ); this.data = ko.observableArray( data.data ); } ko.applyBindings( new model( data ) ); ​ </code></pre> <p>The table stops rendering after the first occurence of the <code>names.abbr</code> binding...am I doing something wrong or is this a bug?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload