I'm on Rails 4 using the latest Cocoon gem. Everything is working perfectly; my only issue is that when I remove nested fields, the add link persists. As in the README, the link for add is in _form while the link for remove is in _[model]_fields. I'm using SimpleForm:
_form.html.erb
<%= simple_form_for(@group) do |f| %>
<%= f.input :name, :label_html => { class: "col-md-2" }, :input_html => { class: "col-md-10" } %>
<div id="group_names">
<%= f.simple_fields_for :group_names do |subgroup| %>
<%= render 'group_name_fields', :f => subgroup %>
<div class="links">
<%= link_to_add_association 'add', f, :group_names %>
</div>
<% end %>
</div>
<% end %>
_group_names_fields.html.erb
<div class="nested-fields">
<%= f.input :subgroup, :label_html => { class: "col-md-2" }, :input_html => { class: "col-md-10" }, :required => false %>
<%= link_to_remove_association "remove", f %>
</div>
What did I miss? Note: I am not missing a submit button, submission works as does deletion. It's just that the add link does not go away. For something this simple I am sure I have simply done something wrong, but I cannot seem to spot it. Otherwise, I am thinking about wrapping the add link in an if statement but I'm not sure what that condition could be.
Thanks!