I have used gem 'nested_form', '~> 0.3.2' with rails 4, i have to add two fields on click of link_to_add helper method of nested form? How will i customize the javascript of nested form to add for this specific scenario?
I did this using jQuery:
$(document).on('nested:fieldAdded', function(event) {
for (var n = 1; n; n--) {
if ($('.fields').length < 2) {
event.field.clone().insertAfter(event.field);
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.