From 611b15ea7121441859bde230afb660ec4435bf4d Mon Sep 17 00:00:00 2001 From: Georgi Stoyanov Date: Tue, 1 Apr 2014 17:30:05 +0300 Subject: [PATCH] Ignore inputs w/o a name when setting the context --- vendor/assets/javascripts/jquery_nested_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 + '\\]'));