Re-align items horizontally in container if an item is hidden/collapsed

So here’s an interesting one. I’m attempting to create an item page from a database of profiles. It’s quite a simple page in terms of dynamic content (i.e. profile image, bio, external link etc.) but I also have fields for social media / other profiles (i.e. Facebook, Instagram, iTunes, Spotify, etc.) for each profile and I want to have buttons that link to those sites also.
I’ve tried adding icons to a repeater and I figured out how to define the links of the items individually but I cannot set an individual repeater item to hide.

Here’s the code for I wrote for setting the links of the icons:


$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => { //Set ‘Where to listen’ Links
$w(“#artistWhereToListen”).forItems([“item1”], ($item, itemData, index) => { //Apple Music
$item(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkAppleMusic;
$item(“#listenIcon”).alt = “Apple Music”;
$item(“#listenIcon”).target = “_blank”;
});
$w(“#artistWhereToListen”).forItems([“item-jqklwbbo”], ($item2, itemData2, index2) => { //iTunes
$item2(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkITunes;
$item2(“#listenIcon”).alt = “iTunes”;
$item2(“#listenIcon”).target = “_blank”;
});
$w(“#artistWhereToListen”).forItems([“item-jqklw87a”], ($item3, itemData3, index3) => { //Spotify
$item3(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkSpotify;
$item3(“#listenIcon”).alt = “Spotify”;
$item3(“#listenIcon”).target = “_blank”;
});
$w(“#artistWhereToListen”).forItems([“item-jqklwcw5”], ($item4, itemData4, index4) => { //Google Play
$item4(“#listenIcon”).link = $w(“#dynamicDataset”).getCurrentItem().linkGooglePlay;
$item4(“#listenIcon”).alt = “Google Play”;
$item4(“#listenIcon”).target = “_blank”;
});
.
.
.
.
});


I need the icons to hide if there is no link for the icon - for each item.
I’ve tried just adding the icons each separately but that would mean that the spacing would look ‘off’ when an item is hidden.

Any suggestions?

@yisrael-wix - hoping you’d have an idea about this one. Thanks.

Sorry, but I’m not too sure what exactly you are trying to do. Do you want to hide an entire repeater item if the links contained within are blank? Or do you just want to hide individual components within the item? The code that you posted doesn’t really explain to me what exactly you’re trying to accomplish.

@yisrael-wix Sorry about that. I thought it was going to be hard to convey what I’m trying to do.

I want to hide an entire repeater item if the links contained within are blank - conditional for each item.

@jacob-waltisbuhl I did some playing around with this and as far as I can tell this can’t be done using the Repeater’s forItem() or onItemReady() functions. You might be able to set the dataset filter to filter out items that don’t have the links. You can do this in the Dataset Settings window:


Under Filter , add all of the filter conditions that would result in valid Repeater items.

@yisrael-wix thanks for getting to that so quickly. I’ve spent quite a bit of time scouring through the Wix Code forums and a lot of other sites too so I half-expected this might be the case. Thanks again.
for this particular situation I was able to compromise and instead just modify the icon itself by hide/show with a second element so that it’s obvious to the user which items can be clicked. This means I don’t have to be annoyed at spacing or allignments at all.

Thanks again.

@jacob-waltisbuhl Glad you worked out something. I still think that a dataset filter might be a good solution. But yeah - that can be for another day.