0

I'm getting this error on line 1620 of backgrid:

Uncaught TypeError: Cannot call method 'text' of null

Here's my code, which imitates the example:

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;
};

The error happens on the foo= line and tags.fetch never gets called.

sprugman
  • 19,351
  • 35
  • 110
  • 163

1 Answers1

0

That's because you are trying to inject HTML into the header. $.text() calls document.createTextNode under the hood and it doesn't accept HTML. You'll have to subclass Header declare its usage explicitly in your column definition.

Y.H Wong
  • 7,151
  • 3
  • 33
  • 35