CanJS EJS表 - 出现在表格上方的行

时间:2013-02-07 04:38:27

标签: ejs canjs canjs-view

我是CanJS的新手并且正在尝试通过教程学习。一旦我被卡住的地方是我将todo tutorial code转换为使用表而不是UL / LI组合。

可能是我犯了一些非常小的错误..但过去3天也找不到相同的内容..有人可以帮忙吗?

todo教程的简短版本(现在使用表格)的jsFiddle是here,您可以在其中看到问题。

来自ejs的代码的关键在于......

<script type='text/ejs' id='todosEjs'>
<table border="1">
    <thead>
    <tr>
        <th>id</th>
        <th>name</th>
        <th>status</th>
    </tr>
    </thead>
    <tbody>
<!-- bind to changes in the todo list -->
<% this.each(function( todo ) { %> 
    <!-- add the todo to the element's data -->
    <tr <%= (el) -> el.data('todo',todo) %>>
        <td>
            <input type="checkbox" <%= todo.attr('complete') ? 'checked' : '' %>>
        </td>
        <td><%= todo.attr('name') %></td>
        <td><%= todo.attr('id') %></td>
    </tr>
<% }) %>
 </tbody>
</table>

</script> 

期待帮助: - )

1 个答案:

答案 0 :(得分:2)

更新:这是a bug的结果,现已修复

看起来评论是这里的问题。删除它们会使其有效,请参阅the updated Fiddle

<table border="1">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>status</th>
    </tr>
<% this.each(function( todo ) { %> 
    <tr <%= (el) -> el.data('todo',todo) %>>
        <td>
            <input type="checkbox" <%= todo.attr('complete') ? 'checked' : '' %>>
        </td>
        <td><%= todo.attr('name') %></td>
        <td><%= todo.attr('id') %></td>
    </tr>
<% }) %>