I’ve been struggling with this problem for the past 2 days and still
haven’t found a good solution - any help would be appreciated!
I have a ‘list’ page that lists all products from a DB. On top of that
listing I have a little box where the user can specify ‘filter’
parameters (eg, book name equals ‘foo’). The list below is refreshed
via ajax everytime one of these filter parameters changes.
What I am trying to do is make the filter parameters persistent
throughout the session, ie if the user set a filter (name, type of book,
etc) in the filter box on the list page, then leaves the list view to do
something else (eg look at the details of one of the books), and then
returns, I’d like a) the list on the list page to still be filtered and,
more importantly, I’d like b) the various text_fields that make up the
filter box to be populated with the values the user selected earlier.
I can do a) with a Filter class that I added to the book model which
generates a SQL conditions string according to the user selections. I’m
struggling with b) - I can’t find an elegant way to preserve the
text_field states between sessions. I’ve tried putting the filter box
into a new controller and model, but then I run into problems because
the filter model doesn’t have any database backend.
Thanks for any suggestions you might have!!