Skip to content

Commit

Permalink
Improved the indexOf check that adds to repeaterFieldsToWatch, Doesn'…
Browse files Browse the repository at this point in the history
…t run multiple times on load now.
  • Loading branch information
graham73may committed Nov 30, 2016
1 parent 6ef8e59 commit 529db88
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions web/conditional-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@
if (allRepeaterFields[field]['condition'].hasOwnProperty('field')) {
fieldName = allRepeaterFields[field]['condition']['field'];

regexPattern = new RegExp(name + '\\[\\d+\\]\\[' + fieldName + '\\]');

if (repeaterFieldsToWatch.indexOf(regexPattern.toString()) === -1) {
if (repeaterFieldsToWatch.indexOf(name + '\\[\\d+\\]\\[' + fieldName + '\\]') === -1) {
// Fields to watch the value change of
repeaterFieldsToWatch.push(regexPattern);
repeaterFieldsToWatch.push(name + '\\[\\d+\\]\\[' + fieldName + '\\]');
}

repeaterToAdd = allRepeaterFields[field];
Expand All @@ -77,7 +75,6 @@
repeaterToAdd['repeater'] = name;

// Add this field to the repeaterFields array
//repeaterFields[name + ':' + field] = repeaterToAdd;
repeaterFields[field] = repeaterToAdd;
}
}
Expand Down

0 comments on commit 529db88

Please sign in to comment.