2
我想通過使用選擇並在部分中呈現它來過濾客戶端評論。現在部分加載@ client.comments。我有一個分類加入類別模型。這一切都有效,只需要知道如何獲得select來調用篩選器操作並使用ajax加載部分。感謝您的幫助。Rails 3 - 類別過濾器使用選擇 - 通過Ajax加載部分
類別控制器:
def filter_category
@categories = Category.all
respond_to do |format|
format.js # filter.rjs
end
end
filter.js.erb:
page.replace_html 'client-note-inner',
:partial => 'comments',
:locals => { :com => Category.first.comments }
show.html.erb(客戶端)
<% form_tag(filter_category_path(:id), :method => :put, :class => 'categories', :remote => true, :controller => 'categoires', :action => 'filter') do %>
<label>Categories</label>
<%= select_tag(:category, options_for_select(Category.all.map {|category| [category.name, category.id]}, @category_id)) %>
<% end %>
<div class="client-note-inner">
<%= render :partial => 'comments', :locals => { :com => @comments } %>
</div><!--end client-note-inner-->
希望是有道理的。 乾杯。