Created
February 2, 2013 18:47
-
-
Save andyjbas/4698761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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