我有一个设置,其中有一些注释在页面加载时呈现,然后另一个区域也包含使用.load()
使用ajax请求呈现的注释。
异步加载的注释都具有相同的新表单结构,但是jquery-ujs并没有接受通过ajax请求呈现的注释。
看起来这与rails-jquery github issue无关,因为UJS处理程序甚至没有拿起应该解雇我的ajax lisetenrs的新元素。
问题是表单被提交/重定向到创建操作(不是通过,而是通过),因此很清楚jquery-ujs处理程序没有拾取通过ajax请求。
我使用jquery-rails 3.1.1在Rails 3.2上。
这是jquery-rails上的错误还是别的什么?
以下是一些相关代码:
控制器
class CommentsController < ApplicationController
layout false
def create
@comment = Comment.new(params[:comment])
@comment.save
respond_to do |format|
format.html
end
end
end
表单部分用于概述和异步评论,表单是通过&#39;添加&#39;提交的。按钮
<%= form_for :comment,
url: project_comments_path(@project),
html: { :class => "newcommentform", style: "display:none" },
method: :post, remote: true do |f| %>
<%= f.text_area :comment_text,
{ rows: 5, cols: 30, disabled: true, html: { style: "width: 100%"} } %>
<%= f.hidden_field :user_id, value: current_user.id %>
<%= f.hidden_field :section, value: section %>
<%= f.hidden_field :commentable_id, value: @project.id %>
<%= f.hidden_field :commentable_type, value: comment_type %>
<br />
<a href="#" class="newcommentcancel">Cancel</a>
<%= f.submit "Add", remote: true, method: :post, :class => 'newcommentform', data: {type: 'html'} %>
<% end %>