agenda-libre-ruby/app/assets/javascripts/pagination.coffee

16 lines
589 B
CoffeeScript
Raw Normal View History

2016-01-10 14:41:20 +01:00
# Automatic ajax pagination
$(document).on 'turbolinks:load', ->
2018-07-17 00:47:48 +02:00
$('.pagination .next a').attr('data-remote', true).each ->
# Go to the next page when page is scrolled
$(document).scroll =>
if $(this).visible true, true
# "Next" link is also hidden while pagination is done
$(this).click().parents('.pagination').hide()
$(document).on 'ajax:success', '.pagination .next a', (event, data) ->
$(this).parents('tfoot').prev().append $('tbody tr', data)
next = $('.pagination .next a', data).attr 'href'
if next?
$(this).attr('href', next).parents('.pagination').show()