Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Infinite scrolling solution covered in revised episode #114:
$('#products').append('<%= j render(@products) %>');
<% if @products.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@products) %>');
<% else %>
<% end %>
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').text("Fetching more products...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment