Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

CanJS + list of tbody gives unexpected nesting

$
0
0
Do this with something like <ol> and <li> and it seems to work fine.

Try it with a <table> and <tbody> (so you get multiple tbody sections) and you end up with a structure like:
  1. <table>
  2.   <tbody>
  3.     <tbody class="from list">...</tbody>
  4.     <tbody class="from list">...</tbody>
  5.   </tbody>
  6. </table>
Template (ejs) is basically:
  1. <table>
  2. <% lines.forEach(function(line) { %>
  3.     <% console.log(line); %>
  4.     <tbody class="from list">
  5.     <tr><td>x</td><td>x</td><td>x</td></tr>
  6.     </tbody>
  7. <% }) %>
  8. </table>
The console.log() is showing me that I'm looping the correct number of times.

Presumably something is adding a default <tbody> when it creates the <table> and then the templating ends up nesting incorrectly. Not entirely clear what/how, since the <table> shouldn't get created until the template is run.

Reproduced this with Firefox 18 and Chrome something-recent.



UPDATE:

Oddly enough, I've just discovered that if I place the <table> tag in the html rather than the template then it renders just fine.

So - when the template starts to render the table it adds a tbody - anyone know why?

TIA

Viewing all articles
Browse latest Browse all 3491

Trending Articles