Skip to content

Instantly share code, notes, and snippets.

@andyjbas
Created February 2, 2013 18:47
Show Gist options
  • Select an option

  • Save andyjbas/4698761 to your computer and use it in GitHub Desktop.

Select an option

Save andyjbas/4698761 to your computer and use it in GitHub Desktop.

Revisions

  1. andyjbas created this gist Feb 2, 2013.
    26 changes: 26 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    // 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 %>