我尝试渲染一个包含四列的表格视图,'名称','生日','性别','已婚& #39;,但是
a)他们的专栏根本没有显示出来 b)我甚至不确定我是否正确传递它们,因为当我在console.log table.options时,columns属性呈现为"空":
Object {columns: Array[0], emptyContent: "no entries", onItemClick: function, sortable: false, onSort: null}
我试过这个:
var table = new Backbone.UI.TableView({
model: people,
columns: [
{ title: "Name", content: 'name' },
{ title: "Gender", content: "gender" } },
{ title: "Birthday", content: "birthday" } },
{ title: "Married", content: "married" } }
]
});
而且:
var table = new Backbone.UI.TableView({
model: people,
options: {
columns: [
{ title: "Name", content: 'name' },
{ title: "Gender", content: "gender" },
{ title: "Birthday", content: "birthday" },
{ title: "Married", content: "married" }
]
}
});
答案 0 :(得分:2)
源代码更改是将选项添加为mu is too short said。将Backbone.UI.TableView对象的initialize方法更改为源代码中的以下内容:
initialize : function(options) { //add parameter
Backbone.UI.CollectionView.prototype.initialize.call(this, arguments);
$(this.el).addClass('table_view');
this._sortState = {reverse : true};
this.options = _.extend({}, this.options, options); //Add this line
}
我确信可能有更好的地方放这个但是我只是通过教程来学习一些高级的主干内容,因为文档与当前版本不匹配我会回避在生产中使用库作为现在。希望它在未来得到修复。