2012-03-17 55 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

相关问题