You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
926 B

# Automatic ajax pagination
# To not setup pagination twice
pager = true
$(document).ready ->
$('.pagination .next a')
.attr('data-remote', true)
.click ->
if pager
pager = false
$(document).on 'ajax:success', '.pagination .next a', (event, data, status, xhr) ->
elts = $('tbody tr', data)
next = $('.pagination .next a', data).attr('href')
if next?
return $(this).show().data('remote', true).attr('href', next)
return $(this).parents('.pagination').remove()
# Go to the next page when page is scrolled
if $('.pagination .next a').size() > 0
$(document).scroll ->
if $(window).scrollTop() == $(document).height() - $(window).height() && $('.pagination .next a').is(':visible')
# "Next" link is also hidden while pagination is done
$('.pagination .next a').hide().click()