// 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 %>