From 449e0e191de2797c4006203588394e098878db1e Mon Sep 17 00:00:00 2001 From: echarp Date: Mon, 18 Jan 2016 00:24:53 +0100 Subject: [PATCH] Important pagination correction --- app/assets/javascripts/pagination.coffee | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/pagination.coffee b/app/assets/javascripts/pagination.coffee index 61099343..cf81b33d 100644 --- a/app/assets/javascripts/pagination.coffee +++ b/app/assets/javascripts/pagination.coffee @@ -1,20 +1,25 @@ # Automatic ajax pagination + +# To not setup pagination twice +pager = true $(document).ready -> $('.pagination .next a') .attr('data-remote', true) .click -> $('#loading').fadeIn() - $(document).on 'ajax:success', '.pagination .next a', (event, data, status, xhr) -> - $('#loading').fadeOut() - elts = $('tbody tr', data) - $(this).parents('tfoot').prev().append(elts) + if pager + pager = false + $(document).on 'ajax:success', '.pagination .next a', (event, data, status, xhr) -> + $('#loading').fadeOut() + elts = $('tbody tr', data) + $(this).parents('tfoot').prev().append(elts) - next = $('.pagination .next a', data).attr('href') - if next? - return $(this).show().data('remote', true).attr('href', next) - else - return $(this).parents('.pagination').remove() + next = $('.pagination .next a', data).attr('href') + if next? + return $(this).show().data('remote', true).attr('href', next) + else + return $(this).parents('.pagination').remove() # Go to the next page when page is scrolled if $('.pagination .next a').size() > 0