views:

37

answers:

1

I have implemented pagination using the will_paginate plugin.

I want have a drop down list where the user can display what number of records they display on each "page". The idea is once they select something, the current screen gets refreshed with the adjust number of records displaying.

The code I have isn't triggering a refresh... what am I doing wrong?

Drop down list:

<%= select_tag :paginate_size, options_for_select([['Disp 5', 5],['Disp 10',10],['Disp: 20', 20]]), :onchange => remote_function(:url => {:action => :show_my_entries, :page_size => "this.options[this.selectedIndex].value"} )%>

In the controller show_my_entries function:

@entries_paginate = Entry.paginate :page => params[:page], :order => 'title', :per_page => params[:page_size], :conditions => "publication_id = " + session[:publication_id].to_s
+1  A: 

I think you need to pass params to :show_my_entries using :with, something like this:

<%= select_tag :paginate_size, options_for_select([['Disp 5', 5],['Disp 10',10],['Disp: 20', 20]]), :onchange => remote_function(:url => {:action => :show_my_entries }, :with => "'paginate_size='+value" )%>

Notice the second param to remote_function.

Jim Jones
Thanks for the answer!
nktokyo