Skip to content
Extraits de code Groupes Projets
Valider e712c991 rédigé par echarp's avatar echarp
Parcourir les fichiers

Simplified automatic pagination

parent 244a0a8f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -11,6 +11,7 @@
# about supported directives.
#
#= require jquery3
#= require jquery_ujs
#= require jquery-sparkline
# For tags input
#= require jquery-ui/widgets/autocomplete
......
# Automatic ajax pagination
# To not setup pagination twice
pager = true
$(document).on 'turbolinks:load', ->
$('.pagination .next a')
.attr('data-remote', true)
.click ->
$('#loading').fadeIn()
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()
# Go to the next page when page is scrolled
$(document).scroll ->
$('.pagination .next a:visible').filter =>
this.visible()
.hide().click() # "Next" link is hidden while pagination is done
$('.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()
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter