help! hiding a section if the reference fields is empty


this is the element (section7).
i have also tried to do this:

$w.onReady(function () {
   $w("#dataset1").onReady( () => { 

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

       if (item.reference===null) {
          $w("#section7").hide();
          $w("#section7").collapse();
          

       } else {
          $w("#section7").show();
          $w("#section7").expand();

       }

    } );


    });



but it still doesnt work.
it doesnt hide the section! on pages that are not connected to an element in the nutrition database the section shows but doesnt display connected content, like so:


note: this image is a placeholder. the text and the image are cconnected to the nutrition dataset.