在我的信息中心index.html.erb
视图中,我有几个关于ajax调用的链接:
<% @employees.each do |employee| %>
<%= link_to employee.full_name, employee_details_path(:assigned_user_id => employee.assigned_user_id), remote: true, class: "employee-select" %></br>
<% end %>
点击该链接会显示部分内容。
dashboard_controller.rb
def employee_details
@latest_report = Report.where(:assigned_user_id => params[:assigned_user_id])
end
employee_details.js.erb
$('#employee-details').html("<%= escape_javascript (render partial: 'employee_details') %>");
我现在想要的是在点击时调用ajax而不是多个链接,我想要一个调用ajax的select_tag。类似的东西:
<%= select_tag "employees", options_from_collection_for_select(@employees, "assigned_user_id", "full_name"),
:prompt => "Please select an employee",
:onchange => "call ajax and render partial" %>
我现在完全被困住了。