Repeater collapse based on button link or label

Unable to get code to collapse a button based on an undefined link or blank label.

Have tried the following variations:

if (!$w( " #button6 " ).link) {

if (!$w( " #button6 " ).link === undefined) {

if (!$w( " #button6 " ).label) {

if (!$w( " #button6 " ).label === “”) {

and even putting in some valid text to see if I can trigger anything.

Please note that my button label and link is retrieved from another reference database through the repeater but since I’m executing this on an onitemReady I am assuming that the values are available within the repeater.

In verbose mode I think I see the correct values in the buttons …

Feel I am missing something fundamental.

Would very much appreciate some comments.

====

Here’s the code with one of the variations to see if I could trigger the collapse by loading an actual text value. Don’t seem to be able to do that either. Argh.

$w( “#repeater1” ).onItemReady(() =>{
if (!itemData.description) {
$w( “#text85” ).collapse();
$w( “#box5” ).collapse();
}
if (!$w( “#button6” ).label === “-” ) {
$w( “#button6” ).collapse();
}
if ($w( “#button7” ).label === “-” ) {
$w( “#button7” ).collapse();
}

});
//Add your code for this event here:
}

Have you searched for and read previous forum posts about this, as you can find a good few that can help you already like these…
https://www.wix.com/corvid/forum/community-discussion/if-else-collapse-for-repeater-items
https://www.wix.com/corvid/forum/community-discussion/hide-repeater-contents-based-on-data
https://www.wix.com/corvid/forum/community-discussion/collapse-empty-elements-in-a-repeater
https://www.wix.com/corvid/forum/community-discussion/collapsing-empty-text-fields

Plus you will need to change your first line for the repeater onReady.

$w("#repeater1").onItemReady(($item, itemData, index) => {

Along with $w to $item.

You use $item instead of the typical $w when you reference a repeater item.

This is also mentioned in the last link above too, which should be the most beneficial to your question.

You can find out more about it by reading about Repeater in the Wix API Reference and looking at the ‘Repeated Item Scope’.

As well as reading the original forum post about the removal of the $w Parameter here.

You will find in many places within the Wix API Reference this short statement reminding you about it too, it will lead you to the forum post linked above if you follow it.

Deprecation note:
The $w parameter of event handlers is being deprecated. To get a scoped selector for working with elements in repeater items, use the $w.at() function and pass it the context property of the event parameter: $item = $w.at(event.context). To learn more, see here.