开发者

Rails 3 - Forms - Jquery :remote make duplicates and prompts 2x?

开发者 https://www.devze.com 2023-02-22 08:15 出处:网络
Hi Im working with a form and have added :remote => true to the form and the destroy link. But when I do that this happends:

Hi Im working with a form and have added :remote => true to the form and the destroy link. But when I do that this happends:

  1. I submit the form and it makes 2 versions that are the same.
  2. I destroy, I get prompted twice?
  3. If i remove the :remote => true it only makes one version and only prompt once.

This is my form

<%= form_for([@comment], :remote => true) do |f| %>
    <% if @comment.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>

          <ul>
            <% @comment.errors.full_messages.each do |msg| %>
                <li><%= msg %></li>
            <% end %>
          </ul>
        </div>
    <% end %>

    <div class="field">
      <%= f.label :title %>
      <br/>
      <%= f.text_field :title %>
    </div>
    <div class="field">
      <%= f.label :body %>
      <br/>
      <%= f.text_area :body %>
    </div>
    <div class="field">
      <%= f.hidden_field :user_id %>
      <%= f.hidden_field :retailer_id %>

      <%= f.hidden_field :product_id %>
    </div>
    <div class="actions">
      <%= f.submit %&g开发者_运维百科t;
    </div>
<% end %>

This is my destroy link

  <%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete, :remote => true %>

Am I doing something very wrong here? Thanks in advance!


I think you have included your rails.js file twice. that might be the problem. check it.

0

精彩评论

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