Hide elements with no content

I have set up a client list backend in my site so that I can quickly and easily pull up client content in one place. However, not all the clients have the same content and I would like those items to automatically hide. For example, one client might have a link to a preview site while another might have a link to a mood board but no preview.

Simply put, I want items that show up in the repeater that have no content to simply disappear. Does that make sense? I’ve attached a screenshot.

You can do it in the code. Something like:

$w("#repeater").forEachItem( ($w, itemData, index) => {
    if (itemData.moodBoard === "") $w("#moodboard").hide();
    if (itemData.previewSite === "") $w("#previewsite").hide(); 
    .
    .
    . 
});

Wow! Thanks for the quick reply!
I tried that out, but did not get it to work. I’ve attached a screenshot. In this case, the “Preview Site” button has no data yet still appears in the “Preview” mode. I checked to make sure my labels are all correct, including capitalization. Any ideas?

Okay … I was assuming you had coded repeaters before.

You have to set up the “data” array for the repeater first and assign it to the repeater.
After that you can have the forEachItem code.

Got it. Thanks!

All good :smiley:

Can you post an example or explain more on how to assign the “Data” array to the repeater?

Hi Tj,
This reference will be useful
Roi