RJS: Ajaxified select_tag

后端 未结 1 1217
心在旅途
心在旅途 2021-01-20 16:44

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 AJ

相关标签:
1条回答
  • 2021-01-20 17:26

    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])
    
    0 讨论(0)
提交回复
热议问题