Open zhm opened 8 years ago
Add a function to handle the common pattern of wanting "all elements under this container" (section or repeatable).
Currently we have:
// all direct child element of the repeatable FIELD('repeatable').elements
But many, if not most times, it's desirable to have all of the repeatable's descendants.
FIELDS('repeatable');
Possible implementation:
function FIELDS(dataName) { var eachRecursive = function(elements, iterator) { elements.forEach(function(element) { if (element.elements) { eachRecursive(element.elements, iterator); } iterator(element); }); }; var elements = []; eachRecursive(FIELD(dataName), function(element) { elements.push(element); }); return elements; }
Add a function to handle the common pattern of wanting "all elements under this container" (section or repeatable).
Currently we have:
But many, if not most times, it's desirable to have all of the repeatable's descendants.
Possible implementation: