Get list of all items in a repeater

Is there a way I can get a list of all of the item IDs inside of a repeater without knowing the ID of the container in the repeater?

I have created a drop down search/select box that I want to use in lots of places on my site. I don’t want to go through the hassle of giving unique names to all of the elements every time I copy it. I have a Box that contains an input text element and a repeater. Inside the repeater I have a text box and a box. When I replicate this unit I want to be able to give the top level container a name, like #customerSearch. I can get a list of child elements IDs on this container with $w(‘#customerSearch’).children which returns the #repeater and the #input IDs. I can’t seem to get the ID for the container inside of the repeater as $w(‘#repeater’).children does not work. So, without knowing the name of the container in the repeater, how do I get a list of all of the items inside that container?

If I know the name of that container, I can just use $w(‘#someContainer’).children . I want to be able to just plunk these blocks down and not worry about having to name them.

Thanks!

The repeater has no children property according to API Docs. You might be able to execute this one on the found repeater.

$w("#myRepeater").forEachItem( ($item, itemData, index) => {
  let repeatedElementsId = $item.id;
} );

Andreas, thanks for the idea. I tried this and I get undefined for the $item.id. It doesn’t matter if I run this before or after I have populated the repeater with some data. The index is correct, but the $item.id is always undefined.

console.log($w(‘#search’).parent.id);
console.log($w(‘#repeater’).parent.id);
$w(“#repeater”).forEachItem( ($item, itemData, index) => {
console.log($item.id);
console.log(index);
} );

The $item in this example returns ‘function’ when I do a typeof $item. So that explains why the .id does not work, because its not an object its a function.