fixed multisort error on an empty table

This commit is contained in:
Rob Garrison 2011-08-19 11:40:12 -05:00
parent c0273a4e3c
commit 8967b5d7f3
5 changed files with 19 additions and 9 deletions

View File

@ -28,6 +28,10 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs
View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt).
#### Version 2.0.13 (2011-08-19)
* Fixed a problem where a javascript error would occur when initializing a multi sort on an empty table. Thanks again to Eugene Ivakhiv!
#### Version 2.0.12 (2011-08-19)
* Updated the `textExtraction` functionality

View File

@ -1,5 +1,10 @@
TableSorter Change Log
Version 2.0.13 (2011-08-19)
============================
* Fixed a problem where a javascript error would occur when initializing a multi sort on an empty table. Thanks again to Eugene Ivakhiv!
Version 2.0.12 (2011-08-19)
============================

View File

@ -29,7 +29,9 @@
}
*/
// define a custom text extraction function for each column
// Define a custom text extraction function for each column
// In this example, textExtraction 1-5 functions don't really need to
// be defined, since they can also be obtained using `$(node).text()`
textExtraction: {
0: function(node) { return $(node).find("strong").text(); },
1: function(node) { return $(node).find("div").text(); },

View File

@ -1,6 +1,6 @@
/*
* TableSorter 2.0 - Client-side table sorting with ease!
* Version 2.0.12
* Version 2.0.13
* @requires jQuery v1.2.3
*
* Copyright (c) 2007 Christian Bach
@ -139,7 +139,7 @@
if (typeof(te) === "function") {
text = te(node);
} else if (typeof(te) === "object" && te.hasOwnProperty(cellIndex)){
text = config.textExtraction[cellIndex](node);
text = te[cellIndex](node);
} else {
text = $(node).text();
}
@ -280,6 +280,7 @@
}
function appendToTable(table, cache) {
if (cache.row.length === 0) { return; }
var c = cache,
r = c.row,
n = c.normalized,
@ -487,6 +488,7 @@
/* sorting methods - reverted sorting method back to version 2.0.3 */
function multisort(table,sortList,cache) {
if (cache.row.length === 0) { return cache; } // nothing to sort
var dynamicExp = "var sortWrapper = function(a,b) {",
col, mx = 0, dir = 0, tc = table.config, lc = cache.normalized.length,
l = sortList.length, sortTime, i, j, c, s, e, order, orgOrderCol;
@ -674,10 +676,7 @@
setTimeout(function () {
// set css for headers
setHeadersCss($this[0], $headers, config.sortList, sortCSS);
appendToTable(
$this[0], multisort(
$this[0], config.sortList, cache)
);
appendToTable($this[0], multisort($this[0], config.sortList, cache));
}, 1);
// stop normal event by returning false
return false;

File diff suppressed because one or more lines are too long