Skip to content

Instantly share code, notes, and snippets.

@andyjbas
Created February 2, 2013 18:47
Show Gist options
  • Save andyjbas/4698761 to your computer and use it in GitHub Desktop.
Save andyjbas/4698761 to your computer and use it in GitHub Desktop.
// grab new items html
var newItems = "<%= j render(partial: 'endless_append', locals: { items: @feed_items }) %>";
// fetch the scroll position
// used to set the window location back after below hack
var scroll_position = $(window).scrollTop();
// append new items to isotope, as usual
$("#feed_list").append( newItems );
// remove all isotope functionality
// isotope is not otherwise detecting the existance of
// the newely appended elements regardless of approach
$("#feed_list").isotope("destroy");
// reloads isotope layout for entire page
// after layout callback returns the window position
// to the position before append was fired
reloadIsotopeScroll(scroll_position);
// reset pagination
<% if @feed_items.next_page %>
$('#paginateFeed .pagination').replaceWith('<%= j will_paginate(@feed_items) %>');
<% else %>
$('#paginateFeed .pagination').remove();
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment