mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Custom pager controls: fix control updates for multiple tables
see http://stackoverflow.com/q/25805547
This commit is contained in:
parent
fd9598b9ab
commit
3e466e9936
@ -32,7 +32,8 @@ $.tablesorter.customPagerControls = function(settings) {
|
|||||||
addKeyboard : true // add left/right keyboard arrows to change current page
|
addKeyboard : true // add left/right keyboard arrows to change current page
|
||||||
},
|
},
|
||||||
options = $.extend({}, defaults, settings),
|
options = $.extend({}, defaults, settings),
|
||||||
$table = $(options.table);
|
$table = $(options.table),
|
||||||
|
$pager = $(options.pager);
|
||||||
|
|
||||||
$table
|
$table
|
||||||
.on('pagerInitialized pagerComplete', function (e, c) {
|
.on('pagerInitialized pagerComplete', function (e, c) {
|
||||||
@ -62,11 +63,11 @@ $.tablesorter.customPagerControls = function(settings) {
|
|||||||
( indx >= pageArray.length - 1 ? '' : options.adjacentSpacer )) + '</span>' );
|
( indx >= pageArray.length - 1 ? '' : options.adjacentSpacer )) + '</span>' );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$('.pagecount').html(pages.html());
|
$pager.find('.pagecount').html(pages.html());
|
||||||
});
|
});
|
||||||
|
|
||||||
// set up pager controls
|
// set up pager controls
|
||||||
$(options.pager).find(options.pageSize).on('click', function () {
|
$pager.find(options.pageSize).on('click', function () {
|
||||||
$(this)
|
$(this)
|
||||||
.addClass(options.currentClass)
|
.addClass(options.currentClass)
|
||||||
.siblings()
|
.siblings()
|
||||||
@ -90,10 +91,10 @@ $.tablesorter.customPagerControls = function(settings) {
|
|||||||
if (/input|select|textarea/i.test(events.target.tagName)) { return; }
|
if (/input|select|textarea/i.test(events.target.tagName)) { return; }
|
||||||
if (events.which === 37) {
|
if (events.which === 37) {
|
||||||
// left
|
// left
|
||||||
$(options.pager).find(options.currentPage).filter('.' + options.currentClass).prevAll(':not(span):first').click();
|
$pager.find(options.currentPage).filter('.' + options.currentClass).prevAll(':not(span):first').click();
|
||||||
} else if (events.which === 39) {
|
} else if (events.which === 39) {
|
||||||
// right
|
// right
|
||||||
$(options.pager).find(options.currentPage).filter('.' + options.currentClass).nextAll(':not(span):first').click();
|
$pager.find(options.currentPage).filter('.' + options.currentClass).nextAll(':not(span):first').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user