diff --git a/public_html/js/Presenters/PagerPresenter.js b/public_html/js/Presenters/PagerPresenter.js index 12317a04..eda3abcd 100644 --- a/public_html/js/Presenters/PagerPresenter.js +++ b/public_html/js/Presenters/PagerPresenter.js @@ -184,12 +184,14 @@ App.Presenters.PagerPresenter = function( } function refreshPageList() { + var $lastItem = $pageList.find('li:last-child'); + var currentPage = pager.getPage(); var pages = pager.getVisiblePages(); - $pageList.empty(); + $pageList.find('li.page').remove(); var lastPage = 0; _.each(pages, function(page) { if (page - lastPage > 1) { - $pageList.append(jQuery('
  • ')); + jQuery('
  • ').insertBefore($lastItem); } lastPage = page; @@ -200,12 +202,23 @@ App.Presenters.PagerPresenter = function( }); $a.addClass('big-button'); $a.text(page); - if (page === pager.getPage()) { + if (page === currentPage) { $a.addClass('active'); } - var $li = jQuery('
  • '); - $li.append($a); - $pageList.append($li); + jQuery('
  • ').append($a).insertBefore($lastItem); + }); + + $pageList.find('li.next a').click(function(e) { + e.preventDefault(); + if (currentPage + 1 < pages.length) { + syncUrl({page: currentPage + 1}); + } + }); + $pageList.find('li.prev a').click(function(e) { + e.preventDefault(); + if (currentPage - 1 >= 1) { + syncUrl({page: currentPage - 1}); + } }); } diff --git a/public_html/templates/pager.tpl b/public_html/templates/pager.tpl index ce71b637..2e25ce34 100644 --- a/public_html/templates/pager.tpl +++ b/public_html/templates/pager.tpl @@ -2,4 +2,6 @@