我在 backgrid 的第 1620 行收到此错误:
Uncaught TypeError: Cannot call method 'text' of null
这是我的代码,它模仿了这个例子:
var ConversionTag = Backbone.Model.extend({});
var ConversionTagCollection = Backbone.Collection.extend({
model: ConversionTag,
url: '/api/tags/conversion',
parse: function(response, options) {
return response.conversionTags;
}
});
var tags = new ConversionTagCollection();
var init = function(parentSelector) {
var columns = [
{ name: 'chanId', label: 'Channel', cell: 'integer' },
{ name: 'name', label: 'Description', cell: 'string' },
{ name: 'pageUrl', label: 'Conversion URL', cell: 'string' },
{ name: 'secureFl', label: 'Secure Tag', cell: 'integer' },
{ name: 'id', label: 'ID', cell: 'integer', editable: false }
];
var grid = new Backgrid.Grid({
columns: columns,
collection: tags
});
var foo = grid.render().$el; // ERROR!
$(parentSelector).append(foo);
tags.fetch();
window.ctags = tags;
window.cgrid = grid;
};
错误发生foo=
在线上并且 tags.fetch
永远不会被调用。