-HeaderRowFixer = function(selector) {
- settings = {
- tables: $(selector),
- thead: []
- };
-
- this.duplicateTheadTr = function() {
- $('>tbody', settings.tables).each(function(){
- $(this).prepend($('thead>tr', this).clone().css('opacity:0'));
- });
- }
- this.fixThead = function() {
- settings.tables.each(function() {
- var widths = [];
- $('> tbody > tr:eq(1) > td', this).each( function(i,v){
- widths.push($(v).width());
- });
- for(i=0;i<widths.length;i++) {
- $('thead th:eq('+i+')', this).width(widths[i]);
- }
- });
- }
-}
-$(function(){
- var fixer = new HeaderRowFixer('.table-fixed-header-row');
- fixer.fixThead();
- fixer.duplicateTheadTr();
- $(window).resize(function(){
- fixer.fixThead();
- });
-});