Backgrid 正在渲染
<table class="backgrid"></table>
但没有别的。未达到 Backgrid:render() 中的断点。我是一个调整别人代码的 Backbone 新手,所以我不确定应该发生什么,但是 LayoutManager:render() 被调用了......它似乎永远不会到达 Backgrid......我想要显示的数据正在被获取并且看起来它们的格式是正确的……但不得不承认,一旦它们被包裹在 Backbone 集合中,就很难分辨。任何关于如何调试/为什么 Backgrid 的渲染没有被调用的指针都被感激地接受了。
下面的代码:
监听视图.js
define([
'backbone',
'underscore',
'backgrid',
'app/models/PersonModel',
'app/collections/PersonCollection',
'app/views/PersonListView',
'hbs!app/templates/listen_template'
],
function(
Backbone,
_,
Backgrid,
Person,
PersonCollection,
PersonListView,
listenTemplate
) {
App = window.App || {};
var ListenView = Backbone.View.extend({
template: listenTemplate,
initialize: function(params) {
//fetch the list of seen people
this.model.attributes.seenPeople.fetch( {
success: function(coll, resp) {
//console.log(coll);
}
});
},
afterRender: function() {
//initialise person view
console.log("creating Backgrid");
this.seenPeopleView = new Backgrid.Grid({
columns: [{
name: "email",
label: "Email",
cell: "string"
},{
name: "id",
label: "ID",
cell: "integer"
}, {
name: "title",
label: "Title",
cell: "string" }
],
collection: this.model.attributes.seenPeople
});
this.seenPeopleView.render();
$('#seen-people-list').append(this.seenPeopleView.el);
}