第二次提交表单,呈现前一个部分以及当前部分

我通过以下方式提交单个文本区域表单:remote => true。 它工作得很好,但是如果我在没有重新加载页面的情况下提交表单两次,则会将部分渲染3次。 在第一次提交后,如果我输入新文本并再次提交,则会加载上一个部分以及当前部分,从而产生3个提交。 它只提交到数据库两次,在页面刷新其中一个消失。 我的控制器看起来像这样:

respond_to do |format| format.html { redirect_to(return_to) } format.js end 

而我的这是我的js:

 $('.comment_form').bind('ajax:success', function(){ $(this).closest('.post').children('.comment_container').prepend(" 'public/comment', :object => @comment) %>"); $('.notice').html('

New Comment Added

'); $(this).children(':input').val(''); $(this).closest('.comment_form_div').slideUp(); return false; });

我只包括jquery和jquery-ujs一次,我尝试设置$.ajaxSetup({cache:false}); 但无济于事。

有没有其他人遇到这个问题?

只是一个抬头以防其他人有这个问题。

我必须做:

 $('#post_form').bind('ajax:complete', function(){ $('#post_form').unbind('ajax:success'); });