-
Notifications
You must be signed in to change notification settings - Fork 1
stephenhandley/jQuery-Another-Infinite-Scroll
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
use like this: $('#things').infinitescroll({next: '#next'}); Using it with Rails: things_controller.rb ====================== def index @items_per_page = 25 @offset = params[:offset] || 0 @things = Thing.where(:limit => @items_per_page + 1, :offset => @offset) if @things.length == @items_per_page + 1 @things.pop @has_more = true @next_url = things_url(:offset => @offset + @items_per_page) else @has_more = false @next_url = nil end respond_to do |format| format.html # this will have the container div and render the partial below into format.json { render :json => { :worked => true, :html => render_to_string(:partial => 'things.html.haml', :collection => @things), :has_more => @has_more, :next_url => @next_url } } end end index.html.haml ======================= - if @things.length > 0 #things = render(:partial => 'things', :collection => @things}) = link_to('next', @next_url, :id => 'next') -else no photos _things.html.haml ======================== - things.each do |thing| = thing.inspect based off of pieces from https://github.com/brianmario/jquery-infinite-scroll and https://github.com/paulirish/infinite-scroll TODO: - start hiding next link and add loading indicator - convert this to markdown
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published