Hi there,
I have a paginated list, and a select box of numbers showing how many pages to display. When the user picks a value I want the screen to refresh with the resized list.
View:
<%= select_tag :paginate_size, options_for_select([['Display: 5', 5],['Display: 10',10],['Display: 20', 20],['Display: 30', 30],['Display: 50', 50],['Display: 100',100]]), :onchange => remote_function(:url => {:action => :show_my_entries}, :with =>"'paginate_size='+value")%>
When I select a value I can see in the log that the show_my_entries function is being called and sent the paginate_size parameter.
In the controller I set the per_page variable as shown below, however selecting anything in the list doesn't refresh the screen with the new list size:
def show_my_entries
if (params[:paginate_size].nil?)
paginate_size = 8
else
paginate_size = params[:paginate_size]
end
@entries = Entry.find_all_my_entries_by_pub(session[:publication_id], session[:user_id])
@entries_paginate = Entry.paginate :page => params[:page], :order => 'title', :per_page => paginate_size,
:conditions => "publication_id = " + session[:publication_id].to_s + " AND writer_id = " + session[:user_id].to_s
render :layout => "dashboard"
end