我有一个应用程序,我正在尝试使用 :remote 执行 Ajax link_to 以刷新一些 div。当我单击“途中”按钮时,它会更新状态 div,但会使时间 div 消失。这是我的代码:
index.html.erb
<h1>MDT Interface</h1>
<div class="row">
<div class="span9">
<div id="unitdisplay">
<%= render 'unitdisplay'%>
</div>
<div id="calldisplay">
<%= render 'calldisplay'%>
</div>
</div>
<div id="status" class="span3">
<%= render 'status' %>
<div id="times">
<%= render 'times' %>
</div>
</div>
</div>
index.js.erb
$("#unitdisplay").html("<%= escape_javascript render("unitdisplay") %>");
$("#calldisplay").html("<%= escape_javascript render("calldisplay") %>");
$("#status").html("<%= escape_javascript render("status") %>");
$("#times").html("<%= escape_javascript render("times") %>");
_display.html.erb
<%= link_to 'En Route', en_route_mdt_index_path(:call_id => call.id), :class => 'btn btn-warning', :method => :put, :remote => true %>
mdt_controller.rb
def en_route
@unit = current_user.unit
@unit.status = Status.find_by_unit_status("En Route")
@unit.save
if params.has_key? :call_id
@call = current_user.calls.find(params[:call_id])
@call.en_route_time = Time.zone.now
@call.save
end
@call = Call.open_calls
@open = current_user.calls.open_calls
respond_to do |format|
format.html { redirect_to mdt_path }
end
end
任何帮助表示赞赏。