disable_with 在 Rails 4.2.6 中不工作

disable_with not working in Rails 4.2.6

我正在使用 disable_with 作为提交按钮,它在 Rails 3.2 中工作正常但在 Rails 4.2.6 中不工作。 这是我使用 disable_with:

的表格
<%= semantic_form_for(@account, :url => account_create_path, :html => { :multipart => true, :class => 'acc_create'}) do |f| %>
  <%= u.input :name, :input_html => {:placeholder => "Name", :value => @account.user.name} %>
  <%= u.input :email, :input_html => {:placeholder => "Email", :value => @account.user.email} %>
  <%= f.buttons do %>
    <%= f.commit_button :label => 'Create My Account', :button_html => {:class => 'register  button', :disable_with => 'Wait...', :id => 'user_submit'} %>
  <% end %>
<% end %>

请帮忙。

这不是默认的表单生成器。

请试试这个:

<%= f.commit_button :label => 'Create My Account', :button_html => {:class => 'register  button', 'data-disable-with' => 'Wait...', :id => 'user_submit'} %>

这对你有用

<%= f.commit_button "Create", :button_html => {:class => "btn primary", :disable_with => 'Processing...'} %>
<%= f.submit 'Start Your Membership', :class => 'button', :data => {:disable_with => 'Please Wait...'} %>

您还需要将 jquery 和 jquery-ujs javascript 添加到您的应用程序中。