有没有办法在之前用确认表单运行控制器操作?
我想问用户他/她是否确实要采取以下措施。确认后运行此操作。在其他情况下,什么都不做。
我已经尝试过这段代码:
= form_tag( '#', onclick: "confirm('#{text}')", :controller => :payments, :action => :pay, :subscription_id => subscription_plan) do
= hidden_field_tag 'current_subscription', subscription_plan.id
.payment_button= image_submit_tag "/images/popup/payment/#{label_img}", :value => label.to_s, data: { disable_with: "Please wait..." }
我很有意思,有没有办法在没有JavaScript的情况下做到这一点?
答案 0 :(得分:1)
是的,有方法
.payment_button= image_submit_tag "/images/popup/payment/#{label_img}", :value => label.to_s, data: { confirm: 'Your confirm message', disable_with: "Please wait..." }
或另一种方式是
= form_tag( '#', onsubmit => "return confirm('Are you sure?');", :controller => :payments, :action => :pay, :subscription_id => subscription_plan) do