Greetings,
I've been hitting my head to the wall over this for quite a while now and don't seem to be able to wrap my forementioned head around it. Basically I have a list of users in a selection box and I have two radio buttons: Sort by first name and sort by last name. This is what I have in my view:
<%= radio_button_tag 'sort_by_last_name', 'true', :checked => true, :onchange => '#{remote_function(:url => {:action => "update_users"}, :with => "order=1")}' %> Sort by Last name<br /> <%= radio_button_tag 'sort_by_last_name', 'false', :onchange => '#{remote_function(:url => {:action => "update_users"}, :with => "order=0")}' %> Sort by First name
<div id="users"><%= render :partial => 'users', :object => @users %></div>
This is my partial view: <%= collection_select(nil, :user_id, users, :id, :first_name, {:prompt => "Select user"}) %>
And this is my controller function for update_users:
def update_users if params[:order] == 1 users = User.all else users = User.first end
render :update do |page| page.replace_html 'users', :partial => 'users', :object => users end end
Now I've found a few sources describing on how this should be done, but I haven't been able to get them to work for some unknown reason.