0

I have an app where I'm trying to do an Ajax link_to with :remote to refresh some divs. When I click on the button "En route" it updates the status div but makes the times div disappear. Here is my code:

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

Any help is appreciated.

nulltek
  • 3,247
  • 9
  • 44
  • 94

1 Answers1

0

My index.html.erb had the status div wrapped around the times div. So the divs were not being read by a js/html call. Separated the div and it started working.

nulltek
  • 3,247
  • 9
  • 44
  • 94