开发者

jQuery suppressing 'forward_to' without preventDefault

开发者 https://www.devze.com 2023-03-24 03:29 出处:网络
I have a form that is submitting comments. I want \'forward_to\' to move to another page after a jQuery notice is displayed. There is no \'preventDefault\' in the jQuery code. When the form is submitt

I have a form that is submitting comments. I want 'forward_to' to move to another page after a jQuery notice is displayed. There is no 'preventDefault' in the jQuery code. When the form is submitted, the data is saved, and the jquery notice is displayed, but 'forward_to' is suppressed. When i remove the id from the form the 'forward_to' works. So what is preventing the forward?

form:

<%= form_for @fb_comments, :html => { :'开发者_JAVA百科data-type' => 'html', :id => 'comment' } do |form| %>
    ...
    <%= form.submit "Update FEEDBACK" %>
<% end %>

jquery notice:

//SUBMIT COMMENT CONFIRMATION
$("#comment").submit(function() {
    $.post($(this).attr("action"), $(this).serialize(), null, "script");
    alert("Your comments were emailed.");
    return false;
})

controller:

fbc = FbComments.find(params[:id])
fbc.update_attributes(params[:fb_comments])
redirect_to root_path

Thanks.


I believe the return false; is your issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消