From 324014283d4f3bd75be393b2460b0fbce773703d Mon Sep 17 00:00:00 2001 From: Mottie Date: Tue, 3 Jun 2014 07:58:11 -0500 Subject: [PATCH] Pager: specifically target rows to prevent issues with ember scripts. Fixes #638 --- addons/pager/jquery.tablesorter.pager.js | 8 ++++---- js/widgets/widget-pager.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 26fa83ad..96ac775b 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -221,7 +221,7 @@ var i, lastIndex = 0, c = table.config, - rows = c.$tbodies.eq(0).children(), + rows = c.$tbodies.eq(0).children('tr'), l = rows.length, s = ( p.page * p.size ), e = s + p.size, @@ -332,7 +332,7 @@ // only add new header text if the length matches if ( th && th.length === hl ) { hsh = $t.hasClass('hasStickyHeaders'); - $sh = hsh ? c.widgetOptions.$sticky.children('thead:first').children().children() : ''; + $sh = hsh ? c.widgetOptions.$sticky.children('thead:first').children('tr').children() : ''; $f = $t.find('tfoot tr:first').children(); // don't change td headers (may contain pager) c.$headers.filter('th').each(function(j){ @@ -655,7 +655,7 @@ p = c.pager; if ( !p.ajax ) { c.rowsCopy = rows; - p.totalRows = p.countChildRows ? c.$tbodies.eq(0).children().length : rows.length; + p.totalRows = p.countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length; p.size = $.data(table, 'pagerLastSize') || p.size || 10; p.totalPages = Math.ceil( p.totalRows / p.size ); renderTable(table, rows, p); @@ -730,7 +730,7 @@ .bind('update updateRows updateAll addRows '.split(' ').join('.pager '), function(e){ e.stopPropagation(); fixHeight(table, p); - var $rows = c.$tbodies.eq(0).children(); + var $rows = c.$tbodies.eq(0).children('tr'); p.totalRows = $rows.length - ( p.countChildRows ? 0 : $rows.filter('.' + c.cssChildRow).length ); p.totalPages = Math.ceil( p.totalRows / p.size ); updatePageDisplay(table, p); diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 485743ec..cf2b1f46 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -153,7 +153,7 @@ tsp = ts.pager = { p.$goto = p.$container.find(s.goto); // page size selector p.$size = p.$container.find(s.pageSize); - p.totalRows = c.$tbodies.eq(0).children().length; + p.totalRows = c.$tbodies.eq(0).children('tr').length; p.oldAjaxSuccess = p.oldAjaxSuccess || wo.pager_ajaxObject.success; c.appender = tsp.appender; if (ts.filter && $.inArray('filter', c.widgets) >= 0) { @@ -247,7 +247,7 @@ tsp = ts.pager = { .on('update updateRows updateAll addRows '.split(' ').join('.pager '), function(e){ e.stopPropagation(); tsp.fixHeight(table, c); - var $rows = c.$tbodies.eq(0).children(); + var $rows = c.$tbodies.eq(0).children('tr'); p.totalRows = $rows.length - ( c.widgetOptions.pager_countChildRows ? 0 : $rows.filter('.' + c.cssChildRow).length ); p.totalPages = Math.ceil( p.totalRows / p.size ); tsp.updatePageDisplay(table, c); @@ -428,7 +428,7 @@ tsp = ts.pager = { lastIndex = 0, p = c.pager, wo = c.widgetOptions, - rows = c.$tbodies.eq(0).children(), + rows = c.$tbodies.eq(0).children('tr'), l = rows.length, s = ( p.page * p.size ), e = s + p.size, @@ -534,7 +534,7 @@ tsp = ts.pager = { // only add new header text if the length matches if ( th && th.length === hl ) { hsh = $t.hasClass('hasStickyHeaders'); - $sh = hsh ? wo.$sticky.children('thead:first').children().children() : ''; + $sh = hsh ? wo.$sticky.children('thead:first').children('tr').children() : ''; $f = $t.find('tfoot tr:first').children(); // don't change td headers (may contain pager) c.$headers.filter('th').each(function(j){ @@ -862,7 +862,7 @@ tsp = ts.pager = { p = c.pager; if ( !p.ajax ) { c.rowsCopy = rows; - p.totalRows = c.widgetOptions.pager_countChildRows ? c.$tbodies.eq(0).children().length : rows.length; + p.totalRows = c.widgetOptions.pager_countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length; p.size = $.data(table, 'pagerLastSize') || p.size || wo.pager_size || 10; p.totalPages = Math.ceil( p.totalRows / p.size ); tsp.moveToPage(table, p, true);