Skip to content

Commit bce54d4

Browse files
committed
changed jQuery selector for finding parent in a more precise way in different DOM setups
1 parent 02c5738 commit bce54d4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/generators/nested_form/templates/nested_form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $('form a.add_nested_fields').live('click', function() {
66

77
// Make the context correct by replacing new_<parents> with the generated ID
88
// of each of the parent objects
9-
var context = ($(this).parents('.fields').children('input:first').attr('name') || '').replace(new RegExp('\[[a-z]+\]$'), '');
9+
var context = ($(this).closest('.fields').find('input:first').attr('name') || '').replace(new RegExp('\[[a-z]+\]$'), '');
1010

1111
// context will be something like this for a brand new form:
1212
// project[tasks_attributes][1255929127459][assignments_attributes][1255929128105]

0 commit comments

Comments
 (0)