jQuery plugin making it incredibly easy to implement rich behavior for your nested forms in Rails.
- Really smart defaults
- Super flexible
- Supports nested forms inside nested forms
- Event Callbacks (after_add, after_remove)
- CSS class cycling (defaults to 'odd', 'even') (can be customized / disabled)
- Keyboard Shortcuts (SHIFT-ENTER to add) (can be disabled)
- Automatic focus on first field of added items (can be customized / disabled)
- 3.5K compressed
<div id="people">
<div class="person">
<form><!-- nested form --></form>
<a href="#remove_person">Remove</a>
</div>
<a href="#add_person">Add</a>
</div>
$('.people').has_nested_forms('.person');
<div class="people">
<div class="person">
<form><!-- nested form --></form>
<a href="#remove_person">Remove</a>
<div class="hobbies">
<div class="hobby">
<form><!-- nested, nested form --></form>
<a href="#remove_hobby">Remove</a>
</div>
<a href="#add_hobby">Add</a>
</div>
</div>
<a href="#add_person">Add</a>
</div>
$('.people').has_nested_forms('.person');
$('.hobbies').has_nested_forms('.hobby', { depth: 2 });
See the defaults object in the plugin for a full list of options.
- Keyboard shortcuts are customizable
- Added keyboard support for deletion
- Initial Release
Copyright (c) 2010 Andy Ferra.
Dual licensed under the MIT and GPL licenses: