How do I hide a button linked to the CMS that doesn't have a URL on only one item page?

I’m trying to figure out how to hide a button that’s connected to my CMS when there’s no hyperlink for a specific item. Each item in my dataset has a button displayed on my site, but a few items don’t actually have links. How can I make those buttons hidden when no link exists?

Working in
Wix Studio

Example

yes this is possible

const currentItem = $w('#yourDatasetID').getCurrentItem();

$w.onReady(function () {
     if (!currentItem.databaseFeildID) { $w("#itemToHideID").collapse(); }
});

and this has worked also

$w.onReady(function () {

$w("#dynamicDataset").onReady( () => { 
       let item = $w("#dynamicDataset").getCurrentItem(); 

       if (item.onlineBookingLink) { //change to field key
          $w("#button1").show();
       } else {
          //$w("#button1").collapse();
          $w("#button1").hide();
       }
1 Like