ryanb/nested_form — Issue #114: Dynamic Nested Form link_to_add javascript called twice
Author: OptimisticMonkey
Created: 2011-11-04 19:27:06+00:00
State: open

I am using ryan bates nested_form gem to dynamically add some nested field to a form.

e.g.

<%= f.fields_for :phones do |phone_form| %>
<%= phone_form.text_field :phone_number %>
<% end %>
<%= f.link_to_add "Add a phone", :phones %>

Everything works, except TWO empty fields are added every time the link is clicked.

I placed a breakpoint on $('form a.add_nested_fields').live('click', function() and see it is called twice...

Thanks in advance for any help