我正在尝试呈现一个包含四列的表视图,“姓名”、“生日”、“性别”、“结婚”,但是
a)列根本没有显示b)我甚至不确定我是否正确地传递了它们,因为当我console.log table.options时,列属性被呈现为“空”:
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" }
]
}
});发布于 2014-05-02 22:58:48
源代码更改是将选项添加为mu is too short said。在源代码中将Backbone.UI.TableView对象的初始化方法更改为以下内容:
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
}我确信可能有一个更好的地方来放置它,但我只是通过教程来学习一些高级的主干知识,考虑到文档与当前版本不匹配,我会避免在生产中使用这个库。希望它能在未来得到修复。
https://stackoverflow.com/questions/19434780
复制相似问题