Skip to content
This repository was archived by the owner on Apr 2, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions lib/backgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,7 @@ var HeaderCell = Backgrid.HeaderCell = Backbone.View.extend({
this.$el.append(label);
this.$el.addClass(column.get("name"));
this.$el.addClass(column.get("direction"));
if (column.get('attributes')) { this.$el.attr(column.get('attributes'));}
this.delegateEvents();
return this;
}
Expand Down Expand Up @@ -2222,19 +2223,29 @@ var Header = Backgrid.Header = Backbone.View.extend({
this.columns = new Columns(this.columns);
}

this.row = new Backgrid.HeaderRow({
columns: this.columns,
collection: this.collection
});
var createRow = function() {
this.row = new Backgrid.HeaderRow({
columns: this.columns,
collection: this.collection
});
};
createRow.call(this);

this.listenTo(this.columns, "sort", function() {
createRow.call(this);
this.render();
}.bind(this));
},

/**
Renders this table head with a single row of header cells.
*/
render: function () {
this.$el.empty();
this.$el.append(this.row.render().$el);
this.delegateEvents();
return this;
// Trigger event
this.collection.trigger("backgrid:header:rendered");
},

/**
Expand Down Expand Up @@ -2881,4 +2892,4 @@ var Grid = Backgrid.Grid = Backbone.View.extend({

});
return Backgrid;
}));
}));