From 9a5bc0e0c4f33a1a8a00f608f733f62f04fb4f3b Mon Sep 17 00:00:00 2001 From: Mottie Date: Thu, 22 Nov 2012 11:20:25 -0600 Subject: [PATCH] fixed issue #179 - using addRows on an empty table --- js/jquery.tablesorter.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 5b4982a5..9f076305 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -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 @@ -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"; @@ -23,7 +23,7 @@ var ts = this; - ts.version = "2.4.8"; + ts.version = "2.5"; ts.parsers = []; ts.widgets = []; @@ -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; @@ -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 @@ -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