I managed to do it with an "index.js.erb" file in Rails 4. Just add this coffeescript:
coffeescript
$(window).on 'scroll', ->
if $('.pagination').length
@url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').remove()
$('#articles').append('<div>')
$('#articles div').last().load @url+' #articles', ->
if $('.next_page.disabled').length
$('.pagination').remove()
This loads the next page then uses the pagination on the newly loaded page until there are no more next pages. Just replace "#articles" with the id of your container in the script. Skip the index.js.erb and respond_to jazz.
I managed to do it with an "index.js.erb" file in Rails 4. Just add this coffeescript:
This loads the next page then uses the pagination on the newly loaded page until there are no more next pages. Just replace "#articles" with the id of your container in the script. Skip the index.js.erb and respond_to jazz.