So I have this displayed tags which is connected to my database via code, some of my items have the tags while some others doesn’t. If the item have the tags, it’ll work fine, but if the item doesn’t have the tags, it’ll show the text which i don’t want to be shown. How can i hide the unwanted tags (shown in red arrow) if the item doesn’t have the tags? here’s my code.
PS: the text box which i used for the tags is #text58
$w.onReady(function () {
$w("#dataset1").onReady(function () {
$w("#repeater1").onItemReady(($item, itemData) => {
let tags = itemData.promo;
let tagsHtml = tags.map(tag =>
`<span style="background: #f44336;
border-radius: 5px;
line-height: 2.6;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
margin-left: 0px;
margin-right: 0px;
text-align: center;
color: #ffffff;
font-weight:900;
font-size: 12px">${tag}</span>`)
.join(' ');
$item('#text58').html = tagsHtml;
});
});
});
Here’s some screenshot of it