I am using Backbone.js for my project.
Sorry, I am a Backbone newbie, therefore I may be missing something very trivial.
这是 HTML 片断 :
<table id="notes" class="table">
<thead>
<tr><th>title</th><th>comment</th></tr>
</thead>
<tbody id="notesTableBody">
</tbody>
</table>
这是用来“输入” HTML 的后骨代码:
App.view.NoteListView = Backbone.View.extend({
el:"tbody#notesTableBody",
initialize:function () {
this.model.bind("reset", this.render, this);
},
render:function (eventName) {
_.each(this.model.models, function (note) {
$(this.el).append(new App.view.NoteListItemView({model:note}).render().el);
}, this);
return this;
}
});
为了清楚起见,我还没有贴上 notelitterView
代码,因为我认为它无关紧要。
我的问题是 Backbone 提供的 HTML 代码如下:
<table id="notes" class="table">
<tbody id="notesTableBody">
<tr><td>title 1</td><td>comment 1</td></tr>
</tbody>
</table>
Basically Backbone removed the thead from the table.
I don t understand why - how can I make sure Backbone doesn t remove it?