Collapsing an element in a repeater (per item!)

hi, i am trying to create a repeater that is connected to a dataset. each item has its tags. if an item has no tags, i want a button in the repeater to disappear.
this is my code, but it isnt working, the buttons disappeared in all of the items!
let me know if you need any visual presentation of this.
here is my code:

Hi,

If you would like to conditionally collapse items if there are no tags in the item object, you can use some of the parameters passed in $w.forEachItem().

Starting on Line 8, you can select the current item that is being iterated over using the itemData parameter:

let tags = itemData;

You can then use information from the current item to collapse the current repeated button:

if(!tags.tags){
    $item('#button1').collapse();
}

Note the use of $item instead of $w since you want to target the current repeated item.