Skip to content Skip to sidebar Skip to footer

Rjs: Ajaxified Select_tag

Since I didn't get the expected answer on my last question I'll try to simplify and narrow my question: How can I build a dropdown-menu that uses AJAX (no submit-button) to call t

Solution 1:

How about this:

<% form_for :category, :url => { :action => "show" } do|f| %>
  <%= select_tag :id, options_from_collection_for_select(Category.find(:all), :id, :name),
  { :onchange => "this.form.submit();"} %>
<% end %>

That will call a traditional html call, so it will refresh the entire page (and respond to format.html).

Then the controller will find the category by the submitted [:id]

@category = Category.find(params[:id])

Post a Comment for "Rjs: Ajaxified Select_tag"