nathanvda/cocoon — Issue #25: Disable_with on forms with cocoon
Author: link-er
Created: 2011-10-22 11:34:46+00:00
State: open

Hello
I use :disable_with on submit buttons of my forms, so user can't push the button twice:

<%= f.inputs do %>
<%= f.hidden_field :commentable_id %>
<%= f.hidden_field :commentable_type %>
<%= f.hidden_field :user_id, :value => current_user.id %>
<%= f.input :comment_text, :input_html => { :class => 'wysiwyg'} %>
<% end %>

<%= f.buttons do %>
<%= f.commit_button :button_html => { :disable_with => "#{t('share.wait')}", :class => "wysiwyg_commit_button" } %>
<% end %>

But then I needed to add fields for attachments, like this:

<%=link_to_add_association t('asset.add'), f, :assets%>

<%=form_tag :action => 'create' do %>
<%= @assets.each_with_index do |asset, index| %>
<%= fields_for "assets[#{index}]", asset do |f| %>
<%= f.file_field :data %>
<%= f.text_field :description %>
<% end %>
<% end %>
<% end %>

And....it broke, button is not disabling after push. Maybe I did anything wrong or there is another way to handle such forms?