Ruby on rails 在rails窗体中加载模态。自定义条纹表单
我正在尝试在rails表单的模式中加载付款表单。现在,当我单击“立即购买”时,模态将加载,但表单将提交。我如何让它不提交,直到有人点击模式中的“提交”Ruby on rails 在rails窗体中加载模态。自定义条纹表单,ruby-on-rails,forms,ruby-on-rails-4,stripe-payments,Ruby On Rails,Forms,Ruby On Rails 4,Stripe Payments,我正在尝试在rails表单的模式中加载付款表单。现在,当我单击“立即购买”时,模态将加载,但表单将提交。我如何让它不提交,直到有人点击模式中的“提交” = form_tag foo_path, id: 'payment-form' do -if @store.products == nil Test - @store.products.each_with_index do |product, index| .row
= form_tag foo_path, id: 'payment-form' do
-if @store.products == nil
Test
- @store.products.each_with_index do |product, index|
.row
.col-lg-2
- if current_user
- if store.user_id == current_user.id
= link_to "Delete", product_path(product), data: { method: "delete", confirm: "Are you sure?"}
.col-lg-8
.panel.panel-default
.panel-body
.row
.col-lg-2
%input{:type => "checkbox", :id => "switchName#{index}", :class => "check"}/
%label{:for => "switchName#{index}"}
.col-lg-8
= hidden_field_tag("order_products[][product_id]", product.id)
= product.name
%br
.subheader= number_to_currency(product.cost_in_cents.to_f / 100)
.col-lg-2
= select_tag("order_products[][quanity]", options_for_select([0,1,2,3,4,5,7,8,9,10,11,12,13,14,15]), "data-cost-per-unit" => product.cost_in_cents, id: product.name, class: "drop", :prodindex => index)
.col-lg-2
-if current_user
-else
%span.payment-errors
.text-center
%h2.total-amount
Total:
$0.00
%hr
.text-center
%button.btn.btn-primary.btn-lg{"data-target" => "#myModal", "data-toggle" => "modal"}
Buy Now
默认情况下,当单击
元素时,将提交包含的表单:
如果您在创建按钮时使用{“数据目标”=>“#myModal”,“数据切换”=>“modal”,“键入”=>“button”}
,则应在不提交表单的情况下显示您的模式
然后,如果你想这样做,你就必须在你的模式中处理提交表单的问题。太好了,可以了。现在,我的表格将不会提交到我的模式内。还有什么我必须做的吗?在模态中添加?我的模式内的提交标记如下:
%button.btn.btn primary{:type=>“submit”}立即付款代码>一旦点击,什么都不会发生。只要你的模态在你的打开和关闭中代码>标记,它应该可以工作。