Hi, I have a bunch of partials on a page, and I put a simple paginator in for each. When I click on page 2 of any pagination link for any partial, instead of just rerendering the partial, page 2 for all partials is rendered, instead of just page 2 for only one partial. Any hints? Charlie --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 6/9/07, charlie caroff <charlie.caroff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, I have a bunch of partials on a page, and I put a simple paginator > in for each. When I click on page 2 of any pagination link for any > partial, instead of just rerendering the partial, page 2 for all > partials is rendered, instead of just page 2 for only one partial. > > Any hints? > > CharlieThis is a tough one with no code to look at, but my guess is that when the page is rendered, you use the same paging variable for all the partials, so they all change. My suggestion would be to use AJAX. Create functionality in the controller to render the partials for the specific areas, and then generate the paging controls dynamically within the same partial, that way the other content is not altered. You could do this without AJAX as well, by having different paging variables for each pagable section. -- F. Morgan Whitney http://www.blizzo.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I''m a newbie, so please bear with me. All my partials get their code from one action in my main controller. Here is a sample: def search_results id = params[:id] @search_term = SearchTerm.find(id) @listing_pages, @listings = paginate(:listings, :conditions => ["search_term_id = ? and deleted = ''0''", id], :order => ''position'', :per_page => 50) @recent_search_pages, @recent_searches = paginate(:search_terms, :order => ''updated_at DESC'', :per_page => 10) end Here''s one of my partials, called _recent_searches.rhtml: <div id="pagination" class="left_pagination"><%pagination_links(@recent_search_pages) %></div> <div id="recent_searches" class="left_column_listing"> <% for recent_search in @recent_searches %> <div id="recent_search_item_<%= recent_search.id %>" class="box_left" > <div class="deleted_news_search_result_title"><%link_to(truncate(recent_search.search_term), {:controller => ''admin'', :action => ''research'', :id => recent_search.id}) %></div </div> <% end %> </div> it is rendered in my main view, like so: render :partial => "recent_searches" Is my problem that all my partials are rendered in the same action -- so they draw some pagination method that rails names for me? Should I have a separate action for rendering each partial? If so, how do I get a partial to find the action I want it to find? Charlie On Jun 9, 3:50 am, "Morgan Whitney" <morganwhit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 6/9/07, charlie caroff <charlie.car...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, I have a bunch of partials on a page, and I put a simple paginator > > in for each. When I click on page 2 of any pagination link for any > > partial, instead of just rerendering the partial, page 2 for all > > partials is rendered, instead of just page 2 for only one partial. > > > Any hints? > > > Charlie > > This is a tough one with no code to look at, but my guess is that when > the page is rendered, you use the same paging variable for all the > partials, so they all change. My suggestion would be to use AJAX. > > Create functionality in the controller to render the partials for the > specific areas, and then generate the paging controls dynamically > within the same partial, that way the other content is not altered. > > You could do this without AJAX as well, by having different paging > variables for each pagable section. > > -- > F. Morgan Whitneyhttp://www.blizzo.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pagination is really only intended for one set of pages at a time (like pages in a book). The problem with your code is that "?page=2" won''t be clear if you want page 2 of the listings or the recent searches--I will guess that it will give you both. The built-in paginate method uses the value of params[:page] and isn''t customizable so that you can use two different params. You should be able to use custom pagination and paginate both sets of results. You''ll just need to send two different params for each paginator (let''s say "page" and "rs_page"). I think that''s the easiest way to do it. I wrote up a guide to pagination that might be helpful in getting you started: http://www.nullislove.com/2007/05/24/pagination-in-rails/ If you feel ready to start learning some Ajax, then the previous poster''s suggestion is the best way to do it. Create a regular view for your listings with simple or custom pagination and then put your recent search into a div that Ajax can update when a new page is selected. But if that''s intimidating, you can easily start with custom pagination and graduate to Ajax later. HTH, Kevin Skoglund --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you. This is a great tutorial. I have it working now, with Ajax. Charlie On Jun 10, 7:03 am, Kevin Skoglund <k...-WGmuFPN42W8gMxX8nMqP6gC/G2K4zDHf@public.gmane.org> wrote:> Pagination is really only intended for one set of pages at a time > (like pages in a book). The problem with your code is that "?page=2" > won''t be clear if you want page 2 of the listings or the recent > searches--I will guess that it will give you both. The built-in > paginate method uses the value of params[:page] and isn''t customizable > so that you can use two different params. > > You should be able to use custom pagination and paginate both sets of > results. You''ll just need to send two different params for each > paginator (let''s say "page" and "rs_page"). I think that''s the > easiest way to do it. > > I wrote up a guide to pagination that might be helpful in getting you > started:http://www.nullislove.com/2007/05/24/pagination-in-rails/ > > If you feel ready to start learning some Ajax, then the previous > poster''s suggestion is the best way to do it. Create a regular view > for your listings with simple or custom pagination and then put your > recent search into a div that Ajax can update when a new page is > selected. But if that''s intimidating, you can easily start with > custom pagination and graduate to Ajax later. > > HTH, > Kevin Skoglund--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---