I have an image in a repeater, that pulls a url from my database on a dynamic page. I want that image to only show up when there is a url in the database field, otherwise it should not show. I tried the code below and it works outside of a repeater, but once I add it to my dynamic page and repeater it doesn't work.
Any help is greatly appreciated! I can't be the first to try to do this, but I've searched the forum for weeks and haven't found the solution.
$w.onReady(function () {
//TODO: write your page related code here...
$w("#image5").hide()
$w("#repeater1").forEachItem(($item, itemData, index) => {
let checkvar = $w("#image5").link
let n = checkvar.includes("https")
if (n === true) {
$w('#image5').show();
}
});
});
Thanks JD, unfortunately, it didn't work. However, I found these two post that finally led me to water:
https://www.wix.com/corvid/forum/community-discussion/if-else-collapse-for-repeater-items
https://www.wix.com/corvid/forum/community-discussion/get-and-use-data-from-repeater
import wixData from 'wix-data'; $w.onReady(function () { //TODO: write your page related code here... $w("#repeater1").onItemReady(($w, itemData, index) => { if (itemData.android === null) { $w("#image5").hide(); } if (itemData.iOs === null) { $w("#image6").hide(); } }); });
//..... let checkvar = itemData.link; let n = checkvar.includes("https") if (n === true) { $item('#image5').show(); //.....