1

我遇到了 disable_with 的问题。我在模态中有一个 simple_form 并且 disable_with 不起作用

但在模态框内的 form_tag 中效果很好

这是我的代码

>  <div class="modal-header">       <%= link_to '×', '#', class: 'close', data: {dismiss: 'modal'}, rel: 'tooltip', title: t(".close") %>  
>   <h3><%= t(".title")%></h3>   </div>
> 
>   <div class="modal-body">    <%= simple_form_for(@user_address, url:
> update_addresses_path, remote: true, method: :put, html: {class:
> 'form-horizontal'}) do |f| %>
>           <%= hidden_field_tag :id, @user_address.id %>
>           <%= f.input :nickname %>    
>           <%= f.input :address %>
>           <%= f.input :number %>
>           <%= f.input :complement %>
>           <%= f.input :neighborhood %>
>           <%= f.input :postal_code %>
>           <%= f.association :state, collection: State.all(order: :symbol), label_method: :symbol, input_html: {id: "state_id_order"} %>
>           <%= f.input :city_id, collection: State.all(order: :symbol), as: :grouped_select, group_label_method: :symbol, group_method: :cities, 
> include_blank: true, input_html: {id: "city_id_order"} %>   </div>
> 
>     <div class="modal-footer">
>       <%= link_to_cancel "#", data: {dismiss: "modal"} %>
>       <%= f.button :submit, class: "btn-warning", disable_with: t(".saving") %>
>     </div>   

我该如何解决?

谢谢

4

1 回答 1

2

确保表单的开头和表单的结尾包含提交按钮。并开始诉诸于使用 disable_with 的 3.2 方式

<%= simple_form_for(x) do |f| %>
    <%= f.button :submit, :value => "Submit", data: {"disable-with" => "Creating..."} %>
<% end %>
于 2012-10-03T21:26:28.853 回答