I am trying to hide a videoplayer on a page when there is no video. It’s attached to a dataset that appears on the page. One of the fields displayed on the page is a video url. On some entries, there is no video, so I don’t want the videoplayer to appear . I have tried the code that appears on this page:
That is the suggestion from Wix helpdesk.
This is the code and it does not work:
$w.onReady(() => {
$w("#myDataset").onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w("#myDataset").getCurrentItem();
// Checks if the current item has a value in the "video" field
if (!item.video) {
// Collapses the video player if there is no value for "video"
$w("#videoPlayer").collapse();
}
});
});
I’ve tried and tried and nothing works. I’ve tried alternate code suggestions that don’t work.
What am I doing wrong. Some default video (skyline video) shows on the page on the entries where there is no video. I think that is the problem. Here is the page.
You’ll need to change out the datasetID, repeaterID and videoPlayerID for the IDs of the elements on your page.
You can find your element IDs here when you have selected them.
itemData.videoKey will also need updating to include the key of the video field in the database. When editing the field in the collection, you’ll find the key here:
So for example, it might be itemData.image based on the key I have above.