HI all,
I’m slowly loosing my mind of this one. I thought it would be a simple if statement but I have tried them everywhere in the code and nothing seems to work. Can someone please help me out?
I want my the website link to hide if there is not url entered in the ShowGuide dataset, field name url.
Thanks!
Sylvia
if (itemData.url === ""){
$item('#showLink').hide());
}else {
$item('#showLink').show());
}
import wixData from 'wix-data';
const collectionName = 'ShowGuide';
const fieldToFilterByInCollection = 'menu';
// const fieldToFilterBy2 = 'SubMenu';
$w.onReady(function () {
setRepeatedItemsInRepeater()
loadDataToRepeater()
$w('#menu').onChange((event) => {
const selectedTags = $w('#menu').value
loadDataToRepeater(selectedTags)
})
});
function loadDataToRepeater(selectedMenus = []) {
let dataQuery = wixData.query(collectionName)
//let dataQuery2 = wixData.query(collectionName)
if (selectedMenus.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedMenus)
// if (selectedMenus.label = ("TV Shows") {
// $w('#showLink').hide());
// }
}
// dataQuery2
// .find()
// .then(results => {
// const itemsReadyForRepeater = results.items
// $w('#showGuide').data = itemsReadyForRepeater;
// const isUrlEmpty = itemsReadyForRepeater.url === ""
// if (isUrlEmpty) {
// $w('#showLink').show();
// } else {
// $w('#showLink').hide();
// }
// })
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items
$w('#showGuide').data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w('#noResultsFound').show()
} else {
$w('#noResultsFound').hide()
}
})
}
function setRepeatedItemsInRepeater() {
$w('#showGuide').onItemReady(($item, itemData) => {
$item('#menu').tags = itemData.menu;
$item('#subMenu').tags = itemData.submenu;
$item('#titles').text = itemData.titles;
$item('#description').text = itemData.description;
$item('#showlink').link = itemData.url;
$item('#date').text = itemData.date;
})
}