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.
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.
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?
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.
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.