If database value equals then hide

Hi everyone,

I’m struggling with a feature I want to add to my website and I would appreciate your help.

I have a dynamic page where I show product information depending of what product they click on a repeater. When they are on this dynamic page I show the relevant data of that product coming from my database.

One item of the relevant product can be the number 0, if this is the case I want to hide this text. I tried this with the following code but unfortunately I didn’t manage to get it working.


import wixData from ‘wix-data’;

$w.onReady( async function () {

wixData.query(“dynamicDataset”)
.eq(“finalePrijsColruyt”, 0)
.find() // Run the query
.then( (results) => {
$w(‘#text59’).hide();
}
);
});


I have also tried the following:

import wixData from ‘wix-data’;

$w.onReady( async function () {

let value = $w(“#text59”).text
if (value === “0”){
$w(‘#text59’).hide();
}
else {
$w(‘#text59’).show();
}
});

Since its a dynamic page, use the getCurrentItem() function under the dynamic dataset’s onReady function like below.

$w("#dynamicDataset").onReady( () => {
    let itemObj = $w("#myDataset").getCurrentItem();
    if(itemObj.finalePrijsColruyt === 0) {
       $w("#text59").hide();
    }
} );

Remember to create the onReady event using the Properties Panel or place the above code under the page’s onReady function.

Thank you very much for this! Works perfectly!