Skip to content

Commit

Permalink
fixed issue #179 - using addRows on an empty table
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Nov 22, 2012
1 parent 57d892c commit 9a5bc0e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions js/jquery.tablesorter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TableSorter 2.4.8 - Client-side table sorting with ease!
* TableSorter 2.5 - Client-side table sorting with ease!
* @requires jQuery v1.2.6+
*
* Copyright (c) 2007 Christian Bach
Expand All @@ -14,7 +14,7 @@
* @author Christian Bach/christian.bach@polyester.se
* @contributor Rob Garrison/https://github.com/Mottie/tablesorter
*/
/*jshint evil:true, browser:true, jquery:true, unused:false */
/*jshint browser:true, jquery:true, unused:false */
/*global console:false, alert:false */
!(function($) {
"use strict";
Expand All @@ -23,7 +23,7 @@

var ts = this;

ts.version = "2.4.8";
ts.version = "2.5";

ts.parsers = [];
ts.widgets = [];
Expand Down Expand Up @@ -449,7 +449,7 @@
}

// sort multiple columns
function multisort(table) {
function multisort(table) { /*jshint loopfunc:true */
var dynamicExp, sortWrapper, col, mx = 0, dir = 0, tc = table.config,
sortList = tc.sortList, l = sortList.length, bl = table.tBodies.length,
sortTime, i, j, k, c, cache, lc, s, e, order, orgOrderCol;
Expand Down Expand Up @@ -704,6 +704,10 @@
var i, rows = $row.filter('tr').length,
dat = [], l = $row[0].cells.length, t = this,
tbdy = $(this).find('tbody').index( $row.closest('tbody') );
// fixes adding rows to an empty table - see issue #179
if (!c.parsers) {
c.parsers = buildParserCache(t);
}
// add each row
for (i = 0; i < rows; i++) {
// add each cell
Expand Down Expand Up @@ -1305,6 +1309,7 @@
row = 0;
$tv = $tb.children('tr:visible');
// revered back to using jQuery each - strangely it's the fastest method
/*jshint loopfunc:true */
$tv.each(function(){
$tr = $(this);
// style children rows the same way the parent row was styled
Expand Down

0 comments on commit 9a5bc0e

Please sign in to comment.