Fixed prev/next button behavior in pager
This commit is contained in:
parent
24d8bf5295
commit
a69f8563e8
1 changed files with 19 additions and 18 deletions
|
@ -62,16 +62,8 @@ App.Presenters.PagerPresenter = function(
|
||||||
.fail(loaded);
|
.fail(loaded);
|
||||||
|
|
||||||
if (!endlessScroll) {
|
if (!endlessScroll) {
|
||||||
keyboard.keydown('a', function() {
|
keyboard.keydown('a', navigateToPrevPage);
|
||||||
if (pager.prevPage()) {
|
keyboard.keydown('d', navigateToNextPage);
|
||||||
syncUrl({page: pager.getPage()});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
keyboard.keydown('d', function() {
|
|
||||||
if (pager.nextPage()) {
|
|
||||||
syncUrl({page: pager.getPage()});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +175,19 @@ App.Presenters.PagerPresenter = function(
|
||||||
$pageList.hide();
|
$pageList.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function navigateToPrevPage() {
|
||||||
|
console.log('!');
|
||||||
|
if (pager.prevPage()) {
|
||||||
|
syncUrl({page: pager.getPage()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigateToNextPage() {
|
||||||
|
if (pager.nextPage()) {
|
||||||
|
syncUrl({page: pager.getPage()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refreshPageList() {
|
function refreshPageList() {
|
||||||
var $lastItem = $pageList.find('li:last-child');
|
var $lastItem = $pageList.find('li:last-child');
|
||||||
var currentPage = pager.getPage();
|
var currentPage = pager.getPage();
|
||||||
|
@ -208,17 +213,13 @@ App.Presenters.PagerPresenter = function(
|
||||||
jQuery('<li class="page"/>').append($a).insertBefore($lastItem);
|
jQuery('<li class="page"/>').append($a).insertBefore($lastItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
$pageList.find('li.next a').click(function(e) {
|
$pageList.find('li.next a').unbind('click').bind('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (currentPage + 1 < pages.length) {
|
navigateToNextPage();
|
||||||
syncUrl({page: currentPage + 1});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
$pageList.find('li.prev a').click(function(e) {
|
$pageList.find('li.prev a').unbind('click').bind('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (currentPage - 1 >= 1) {
|
navigateToPrevPage();
|
||||||
syncUrl({page: currentPage - 1});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue