Hide Images and Video.

So I have a page and it has like 3 images and 1 video.
I should display the video only of the Url is there in Database.
Similarly, I should display Images 2 and 3 only when they are present.
If not I need the area to be collapsed, right now I see a blank space and that isnt helping.
I tried changing the code but nothing helped

1 Like

Well i made it to work :slight_smile:

$w.onReady(() => {
$w(β€œ#dynamicDataset”).onReady(() => {
// Checks if the img2 is null and displays only when its there.
if(!($w(β€œ#dynamicDataset”).getCurrentItem().img2)){
$w(β€œ#image2”).collapse();
$w(β€œ#image2”).hide();
}
// Checks if the img3 null and displaysonly when its there.
if(!($w(β€œ#dynamicDataset”).getCurrentItem().img3)){
console.log(β€œInside here5”);
$w(β€œ#image3”).collapse();
$w(β€œ#image3”).hide();
}
// Checks if the tube video is null and displays only when its there.
if(!($w(β€œ#dynamicDataset”).getCurrentItem().tube)){
$w(β€œ#videoPlayer1”).collapse();
$w(β€œ#videoPlayer1”).hide();
}
});
});

Good job :slight_smile: