Code is working in preview mode but not in the live site

Hi developers, I have a simple code for hide and collapse some lightbox’s elements when a dataset’s item is filled, it looks like this, and it’s working perfectly in preview mode, but not in live site, i hope someone can help me, first days coding btw

$w(“#dataset4”).onReady( () => {

   let item = $w("#dataset4").getCurrentItem();  

   if (item.usuario) { 

      $w("#box377").collapse(); 

      $w("#box377").hide(); 

   } else { 

      $w("#box377").show(); 

      $w("#box377").expand(); 

   } 

} );

@mediatility Try putting it inside the page onReady like what follows:

$w.onReady(function () {
    $w("#dataset4").onReady( () => { 
       let item = $w("#dataset4").getCurrentItem(); 
       if (item.usuario) {
          $w("#box377").collapse();
          $w("#box377").hide();
       } else {
          $w("#box377").show();
          $w("#box377").expand();
       }
    });
});

Doing it this way, ensures that the the box element has loaded.

Thank you man! Now is working correctly, I was all day trying to fix it haha :sweat_smile: