2012-03-17 1 views
1

내가 자동으로 게시물을 다시로드하고 사업부의 post_container에 삽입 할 몇 가지 코드 원 :이 레일 내 home.html.erb에 니펫을레일 AJAX로드 '갱신'에 전체 페이지를 DIV

<%= link_to_remote "Update", {:action => 'ajax_update', :id => @posts, :update => 'post_container'}, :confirm => "Are you sure?" %> 

실제로 소요를 전체 페이지 (title, head, body 태그)를 div post_container 내에 배치합니다. 왜? 또한, 내가 말할 수있는 한, ajax_update 함수는 호출되지 않는다.

나는 어떻게하려고합니까? 왜이 전체 페이지로드가 발생합니까? 나는 레일 2.3.11을 사용하고

(편집 :. 또한,이 링크를 클릭 더 확인 대화 상자 없음)

<a confirm="Are you sure?" href="#" onclick="new Ajax.Updater('post_container', '/home', {asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent('uaqM0Ie8to5pprvE6WcF416DN0vNeyO7Xa+JM6VZFY4=')}); return false;">Update</a> 
: 코드 조각의 HTML 출력

EDIT (2) 컨트롤러 액션에서

+0

': remote => true'를 추가 하시겠습니까? – uday

답변

0

=> 거짓 레이아웃을 할 수있는 올바른 방법을 찾을 수 없습니다

레일 2.3.11 API 문서에서 정보를 바탕으로
<%= link_to_remote "Update",:update => 'post_container', :url => {:action => 'ajax_update', :id => @posts, }, :confirm => "Are you sure?" %> 

는 :

http://api.rubyonrails.org/v2.3.11/classes/ActionView/Helpers/PrototypeHelper.html#M002185

또한, 해당 페이지에있는 periodically_call_remote 방법은 클릭이 필요없는 자동 호출에 유용합니다.

0

는 사용

def ajax_update 
    @posts = Post.find(@posts) 
    render :layout => false 
end 
+0

액션은 실제로 실제로 호출되지 않습니다. 다른 모양을 원한다면 HTML 출력을 추가했습니다. – you786