DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Simple Ajax Paging

  • submit to reddit
        <% if @lesson_pages.current.previous -%>
  <%= link_to_remote 'Previous page', 
    :url  => { :page => @lesson_pages.current.previous },
    :update  => 'my_div',
    :loading => "Toggle.display('spinner');"
<% end -%>

This assumes that your paging links are inside the DIV that is being replaced by the Ajax call.

I'll leave 'next' as an exercise for the reader.    


Snippets Manager replied on Mon, 2012/05/07 - 2:14pm

that would make a nice helper.. link_to_remote_next and pref