ajax - Rails remote form submitting duplicate form data -


when submit remote form in rails, form post duplicate data, though if manually serialize form using jquery shows there no duplicates. causing this?

*normally wouldn't problem, 1 of form data array, result there duplicate value in submitted array.

result chrome's network inspector enter image description here

result jquery manual

update here gist of form (removing html markups):

<% @order.available_payment_methods.each |method| %>     <%= radio_button_tag "order[payments_attributes][][payment_method_id]", method.id, method == @order.available_payment_methods.first %>     <%= spree.t(method.name, :scope => :payment_methods, :default => method.name) %>     <%= render :partial => "spree/checkout/payment/#{method.method_type}", :locals => { :payment_method => method } %> <% end %>  # partial     <% param_prefix = "payment_source[#{payment_method.id}]" %>      <%= label_tag "name_on_card_#{payment_method.id}", spree.t(:name_on_card) %><span class="required">     <%= text_field_tag "#{param_prefix}[name]", "#{@order.billing_firstname} #{@order.billing_lastname}", { id: "name_on_card_#{payment_method.id}", class:'form-control'} %>      <% options_hash = rails.env.production? ? {:autocomplete => 'off'} : {} %>     <%= text_field_tag "#{param_prefix}[number]", '', options_hash.merge(:id => 'card_number', :class => 'required cardnumber form-control', :size => 19, :maxlength => 19, :autocomplete => "off") %>       <%= text_field_tag "#{param_prefix}[expiry]", '', :id => 'card_expiry', :class => "required cardexpiry form-control", :placeholder => "mm / yy" %>      <%= text_field_tag "#{param_prefix}[verification_value]", '', options_hash.merge(:id => 'card_code', :class => 'required cardcode form-control', :size => 5) %>     <% if @order.bill_address %>     <%= fields_for "#{param_prefix}[address_attributes]", @order.bill_address |f| %>       <%= render :partial => 'spree/address/form_hidden', :locals => { :form => f } %>     <% end %>   <% end %>   <%= hidden_field_tag "#{param_prefix}[cc_type]", '', :id => "cc_type", :class => 'cctype' %> 

update submitting form without remote: true fixes problem (but need it!)

add onsubmit="return false();" on form make sure form not submited through default form submission. submitted through ajax adding remote: true


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -