Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install ajax_nested_form
//= require ajax_nested_form
Using ActionView helper methods
For creating link to add nested model fields use next syntax
link_to_add_fields "LinkText", form_builder_instance, :association_name, "container_for_adding_fields", "position_for_adding"
Available positions for adding are "first" and "last". Last is used by default.
link_to_add_fields "Add list", f, :lists, "#lists-container", "first"
For creating link to destroy nested model fields use following code
link_to_remove_fields "Remove", form_builder_instance, "nested_model_fields_container"
link_to_remove_fields "Remove", f, ".list-fields"
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request