2012-08-16 3 views
0

저는 일부 div를 새로 고침하기 위해 리모컨과 함께 Ajax link_to를 수행하려고하는 앱이 있습니다. "En route"버튼을 클릭하면 상태 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 

도움이 되었습니까?

답변

0

내 index.html.erb의 상태 div가 시간 div로 둘러 쌉니다. 그래서 div는 js/html 호출로 읽히지 않았습니다. div를 분리하면 작동하기 시작합니다.

관련 문제