2015-05-22 24 views
-1

我想格式和自舉表中的每個循環 所以這是我的我的bookshelper.js文件的代碼:何格式化的自舉表中的每個循環

Template.books.helpers({ 
    'book': function(){ 
     return Books.find(); 
     }  
    }); 

在我books.html文件我已經添加了一個自舉表:

<table class="table table-striped"> 
    <tr> 
    <th>Author</th> 
    <th>Title</th> 
    </tr> 
    {{#each book}} 
    <tbody>{{author}} </tbody> 
    <tbody>{{title}} </tbody> 
    {{/each}} 
    </table> 

這就是結果: http://gyazo.com/52870c76370bed527757a3c7fd5972d5 作者和標題成績是在一列(作者)我怎樣才能將它們劃分在2分各列? My Books mongo收藏非常簡單。它只有一個作者和一個標題屬性。非常感謝您的支持

+0

你知道如何創建一個簡單的表嗎? body> tr> td? – pbenard

回答

0

For reference,表都是這樣設計的:

<table> 
    <thead> 
    <tr> 
     <th>Author</th> 
     <th>Title</th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr> 
     <td>Some Author</td> 
     <td>Some Title</td> 
    </tr> 
    <tr> 
     <td>Some Other Author</td> 
     <td>Some Other Title</td> 
    </tr> 
    <!-- etc --> 
    </tbody> 
</table> 

從這個例子,嘗試用你的each聲明,明確需要重複的部件周圍。應該只有一個table,一個thead和一個tbody(以及它們的/table,0 /thead/tbody當然)在由您的模板處理產生的HTML代碼中。