1
我已添加评论到我的文档。当提交评论时,评论将通过AJAX与新评论部分加载/更新。在这部分内部是加载第二部分(也由ajax加载)的链接,以提交对评论的评论(即评论儿童)。通过ajax加载部分内部父母部分加载ajax
当添加新评论时,部分将按照预期重新加载新评论,但是加载第二部分的链接在没有重新加载页面的情况下不起作用。我相信我需要将第一部分委托给文档中的div或元素,以便JavaScript(加载第二个部分)加载并执行,我如何实现这一目标?这里是我的设置:
Create.js.erb:
$('#ajax').html("<%= j comments(@document, @current_user) %>");
在评论控制器
def create
....
respond_to do |format|
format.js
end
end
里面部分的意见创建动作,第二部分可以加载,提交儿童评论的表格(即对评论的评论TS)。
链接触发第二部分/留下评论的孩子(这里面第一部分)
= link_to "Reply", {:controller => :documents, :action => :show}, { :method => :get, :remote => true}
Show.js.erb:在文件控制器
$('#comment_child_form_<%= @comment_parent.id %>').html("<%= j comment_child_form(@current_user, @document, @comment_parent) %>");
显示行动
def show
....
respond_to do |format|
format.html
format.js
end
end
注:我使用的Rails 3.2.12
目前尚不清楚你使用的是什么rails版本。 – rmagnum2002
加入此聊天http://chat.stackoverflow.com/rooms/34513/http-stackoverflow-com-questions-17965127-loading-partial-via-ajax-inside-paren – rmagnum2002