Ruby on rails 轨道内的远程表单

Ruby on rails 轨道内的远程表单,ruby-on-rails,form-for,Ruby On Rails,Form For,嗨 我尝试在表单_remote _的submit标记中使用javascript函数调用,但找不到im调用的函数。 如果我从form_remote_调用相同的函数,那么ajax将停止工作。 当我使用form_remote_作为非form_remote_标记时,有人能帮我怎么调用javascript函数吗…?我认为remote_form_是您所需要的 例如: 在你看来: <%- remote_form_for(comment, :url => topic_post_comments_pa

嗨 我尝试在表单_remote _的submit标记中使用javascript函数调用,但找不到im调用的函数。 如果我从form_remote_调用相同的函数,那么ajax将停止工作。
当我使用form_remote_作为非form_remote_标记时,有人能帮我怎么调用javascript函数吗…?

我认为remote_form_是您所需要的

例如:

在你看来:

<%- remote_form_for(comment, :url => topic_post_comments_path(@topic, post), 
           :after => "submitComment(self);$('input').disable()") do |f| %>
<%= f.text_field :body, :size => 70, :class => "comment_body" %><br />
<%= f.submit "Submit", :class => "comment_submit" %>
<%- end -%>
无论如何,这只是一个简单的示例,在您对远程表单有了一些感觉之后,您必须处理更多的细节


祝您好运。

如果您提供此表单\u remote\u所依赖的代码部分,将会有所帮助。此外,表单_remote_本身和您正在使用的rjs partial。
@comment = @post.comments.new params[:comment] # actually, it depends on your model :p

respond_to do |format|
  # remember to handle exception here. like if @comment.save or not
  format.html
  format.js { 
    render :update do |page|
      pagepage.visual_effect :highlight, "comments"
    end
  }
end