Pet*_*lis 1 ruby-on-rails onclick formtastic
我试图确保我的rails应用程序的用户无法通过双击多次提交我的formtastic表单.
请参阅下面的代码.
不幸的是,在向提交按钮添加:onclick参数后,表单不再处理.按钮名称简单更改为禁用按钮'正在处理...'(正如提交期间所预期的那样),但此状态是永久性的(没有数据验证和重定向).
我没有看到如何调试这个 - 有人可以帮忙吗?
= semantic_form_for @case, :html => {:class => "form-stacked"} do |f|
= f.inputs :name => "Case" do
= f.input :summary, :input_html => {:class => 'xxlarge main_case'}
= f.buttons do
= f.commit_button "Create Case", :button_html => {:class => "btn primary", :onclick => "this.disabled=true; this.value='Processing...';"}
Run Code Online (Sandbox Code Playgroud)
试一试:
submit_tag "Create Case", :disable_with => "Processing..."
Run Code Online (Sandbox Code Playgroud)
这将适用于rails 3及以上版本
更新:
与formtastic你需要以下
<%= f.action :submit, :button_html => { :label => "create case", :class => "btn primary", :disable_with => 'Processing...' } %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3000 次 |
| 最近记录: |