Skip to content

Commit

Permalink
Fixed a javascript bug when the parent of a nested attribute is not i…
Browse files Browse the repository at this point in the history
…n a "many" relationship.

Example: project[tasks_attributes][assignments_attributes][1] instead of project[tasks_attributes][0][assignments_attributes][1].

Now the parent_ids array is never null.
  • Loading branch information
Paulo Ragonha committed Mar 10, 2011
1 parent 2a01741 commit 4d2029a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/generators/nested_form/templates/jquery_nested_form.js
Expand Up @@ -14,7 +14,7 @@ $('form a.add_nested_fields').live('click', function() {
// project[tasks_attributes][0][assignments_attributes][1]
if(context) {
var parent_names = context.match(/[a-z_]+_attributes/g) || [];
var parent_ids = context.match(/[0-9]+/g);
var parent_ids = context.match(/[0-9]+/g) || [];

for(i = 0; i < parent_names.length; i++) {
if(parent_ids[i]) {
Expand Down
Expand Up @@ -14,7 +14,7 @@ document.observe('click', function(e, el) {
// project[tasks_attributes][0][assignments_attributes][1]
if(context) {
var parent_names = context.match(/[a-z_]+_attributes/g) || [];
var parent_ids = context.match(/[0-9]+/g);
var parent_ids = context.match(/[0-9]+/g) || [];

for(i = 0; i < parent_names.length; i++) {
if(parent_ids[i]) {
Expand Down

0 comments on commit 4d2029a

Please sign in to comment.