Hi ! I’m scratching my head there, hope I can explain my problem clearly
I try to set a repeater linked to a database in order to display images, texts, but also audio. However, some of the elements don’t have any mp3 to be linked to, so I’d like to make the audio player disappear when this is the case.
I tried a lot of codes already that I found on the pages below, but none of them works. No matter what I do, the audio players are always displayed…
https://www.wix.com/corvid/forum/community-discussion/if-else-collapse-for-repeater-items
https://www.wix.com/corvid/forum/community-discussion/hide-an-audio-player-in-repeater-if-there-is-no-audio-file-present-in-dataset?origin=auto_suggest
https://www.wix.com/corvid/forum/community-discussion/collapse-empty-elements-in-a-repeater
Can you see what I’m doing wrong there ?? These are some examples of the codes I tried
$w.onReady(() => {
$w( “#listRepeater” ).onItemReady( ($w, itemData, index) => {
const item = $w( “#dataset1” ).getCurrentItem();
if (!item.mp3) {
$w( “#audioPlayer1” ).hide();
}
});
});
$w( “#listRepeater” ).onItemReady(($w, itemData, index) =>{
if (!itemData.mp3) {
$w( “#audioplayer1” ).collapse();
}
});
$w( “#listRepeater” ).onItemReady( ($w, itemData, index) => {
if (! itemData.mp3) { // based on your “empty status” you need to change this line.
$w( “#audioplayer1” ).hide();
}
});
$w.onReady(() => {
$w( “#dataset1” ).onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w( “#dataset1” ).getCurrentItem();
// Checks if the current item has a value in the “text” field
if (!item.hideMp3) {
// Collapses the audio player if there is no value for “text”
$w( “#audioPlayer1” ).hide();
}
});
});