After I submit(click) the form(submit input tag), the submit tag become disabled, how can I avoid this?
The purpose is add product to cart, target is blank.
After I submit(click) the form(submit input tag), the submit tag become disabled, how can I avoid this?
I need it is always enabled for click.
part of products#index html
<div class="product">
<div class="product-info product-name">土豆</div>
<div class="product-info product-description">个大,均匀,甘甜。</div>
<div class="product-info product-price">¥2.5/ 斤</div>
<div class="product-info">
<%= form_for(@cart, namespace: @product.id, target: "_blank") do |f| %>
<%= f.hidden_field :product_id, value: @product.id, namespace: @product.id %>
<% if current_user %>
<%= f.hidden_field :user_id, value: current_user.id, namespace: @product.id %>
<% end %>
<div><%= f.number_field :amount, min: 1, max: 100, value: 1, required: true, namespace: @product.id %> 斤</div>
<div><%= f.submit "加入购物车", class: 'btn btn-primary' %></div>
<% end %>
</div>
</div>
application.js
$(document).on('turbolinks:load', function() {
$('input[type=submit]', this).attr('disabled', false)
$(".new_cart").attr({
target: '_blank'
});
});
This video show the problem
Try changing the "Add to Cart" "button" so it's not an input field. Try making it a submit button (e.g., "<%= f.submit .... [ whatever else ] ... %>") or just a button <%= f.button "Add to Cart" .... [whatever else]... %>