2012-03-17 52 views
1

我想一些代碼,會自動重新加載的帖子,並將其插入到DIV post_container:Rails的AJAX加載整個頁面爲「更新」 DIV

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

這軌在我home.html.erb片斷,其實需要整個頁面(標題,頭部,主體標籤)並將其放在div post_container中。爲什麼?另外,據我所知,ajax_update函數甚至不會被調用。

我該怎麼做我想做的事?爲什麼整個頁面加載都會發生?我使用Rails 2.3.11

(編輯:也沒有,當你點擊鏈接確認對話框。)

編輯2:

<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輸出
+0

加入':remote => true'? – uday 2012-03-17 03:22:00

回答

0

在你的控制器動作,使用方法:佈局=>假

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

這個動作似乎並沒有真正被調用。如果您想再看一下,我已經將html輸出添加到了問題中 – you786 2012-03-17 04:24:19

相關問題