Collapse/Expand elements in a dynamic page if a field in a database is empty

Hey Mustafa, can you give me some advice? Im trying to do similar thing, colapse a continer box if the “rich text field” on my dtabase is empty. I researched a lot, but no matter what code I use, problem is it is collapsing the Container Box no matter if the field it is empty or not. It’s being a pain :frowning:

Tryed this codes :

Collection name: EspecialidadesColection
Dataset name: LBset
Dataset Rich Text field key: altDesc1
Container box to collapse: box000002

//version 1:

$w.onReady(() => {
    $w("#LBset").onReady(() => {   

 const item = $w("#LBset").getCurrentItem();   // Checks if the current item has a value in the "altDesc1" field
 if (!item.altDesc1) {   // Collapses the image space if there is no value for "altDesc1"
            $w("#box000002").collapse();
          } else {
            $w("#box000002").expand();
        }
    });
});


and this

//version 2:

$w.onReady(() => {
    $w("#LBset").onReady(() => {   
 if(!$w("#LBset").getCurrentItem().altDesc1){
          $w("#box000002").collapse();
       }
    });
});

Both with the same effect, collapses everytime