I am using CListView with a search form. Upon submitting the form, the ListView is updated using $.fn.yiiListView.update in JS.
This is all working fine, including the pagination. What I noticed is the pager automatically generates the correct URL including any additional parameters. For example, if you have Product model you get this kind of URL:
I was wondering, rather than generating this URL on each link, could we change it so that when you click on a pager link, it passes the value of the page number to the search form?
So for example, if I click on page 2 link, rather than performing the default behaviour, I use jQuery to read the page number and pass this value to a hidden input in my search form, e.g. Product[page]. The form then gets submitted and I can retrieve the page number in my controller and return the desired resultset.
Basically I have a refine search filter form, when a filter value is changed the form is posted via AJAX with the filter values. In my controller I read the values and update the CListView.
At the same time I use history.js to construct a URL with the filter values.
What this means is I have a full back button history support with AJAX refine search.
However the pager links are independent to the search filters. When I click a pager link I cannot use back button to go back to previous page.
Now I am aware CListView has an `enableHistory’ option, but I found that was not compatible with my refine search filters.
So what I was hoping to do is rather than the pager link perform the AJAX request, instead pass the requested page number as a hidden input in the refine search form and that way it will be sent alongside all the other filter values.
The refine search form itself uses POST but this is an AJAX post. The page never reloads but I use History.js to create a url with the search parameters.
The pager links perform their own AJAX post. I want to intercept this and instead pass the requested page number to a hidden input on my search form.
EDIT: This topic provided me with some inspiration and I changed my approach: