Note that there are some explanatory texts on larger screens.

plurals
  1. POknockoutjs table inline template troubles
    primarykey
    data
    text
    <p>I slimmed down my actual code but I can't get this work. I am using knockoutjs and bootstrap with inline knockout templates. I use to just put a bunch of input's inside a div but I changed it to a table for alignment reasons. I know the property names are correct and the javascript console doesn't show any errors at all for bad variables or binding issues. I am putting the foreach in a TR tag instead of the TBODY tag because I don't know how many checkboxes I will have every time and I don't want them in rows exactly, just one TR element and a bunch of TD cells inside that one TR tag for now. How can I make this work??</p> <pre><code>&lt;div id="Counties" class="well well-large checkbox inline"&gt; &lt;table class="table table-condensed"&gt; &lt;tbody&gt; &lt;tr data-bind="foreach: { data: counties }"&gt; &lt;td&gt;&lt;input type="checkbox" data-bind="attr: { value: $data.sid }" /&gt;$data.name &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>Here are my viewModels :</p> <pre><code>function searchVm() { var self = this; self.counties = ko.observableArray([]); //array of jurisItem } function jurisItem(name, sid) { var self = this; self.name = name; self.sid = sid; } </code></pre> <p>Edit :</p> <p>I also tried this based on knockoutjs documentation and it doesn't work. I know I can do this in other ways using jquery but I would prefer knockout template syntax...</p> <pre><code>&lt;table class="table table-condensed"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;!-- ko foreach: $root.counties --&gt; &lt;td&gt; &lt;input type="checkbox" data-bind="attr: { value: $data.sid }" /&gt;$data.name &lt;/td&gt; &lt;!-- /ko --&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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