diff --git a/vendor/assets/javascripts/jquery_nested_form.js b/vendor/assets/javascripts/jquery_nested_form.js index 406c3051..f232d957 100644 --- a/vendor/assets/javascripts/jquery_nested_form.js +++ b/vendor/assets/javascripts/jquery_nested_form.js @@ -14,7 +14,7 @@ // Make the context correct by replacing with the generated ID // of each of the parent objects - var context = ($(link).closest('.fields').closestChild('input, textarea, select').eq(0).attr('name') || '').replace(/\[[a-z_]+\]$/, ''); + var context = ($(link).closest('.fields').closestChild('input[name], textarea[name], select[name]').eq(0).attr('name') || '').replace(/\[[a-z_]+\]$/, ''); // If the parent has no inputs we need to strip off the last pair var current = content.match(new RegExp('\\[([a-z_]+)\\]\\[new_' + assoc + '\\]'));