I have a repeater that I am using to display a database. This database is currently empty and I wanted to do a conditional code that if there are no values in the database to show a line of text saying that. This is my code.
import wixData from ‘wix-data’;
wixData.query(‘Job_Post’);
if (‘#dataset1’).value = ‘’;{
$w(“#text194”).show();
$w(“#repeater1”).hide();
} else {
$w(“#text194”).hide();
$w(“#repeater1”).show();
}
Don’t use the wix query line, look in the api and count number of items or check if result.items.totalCount > 0 to show or hide elelemts.
Thanks Andres. I know the count is zero. Can you write a line of code that the equals 0 should look like? It would be a big help.
$w.onReady( () =>
{ $w(“#myDataset”).onReady( () => {
let count = $w(“#myDataset”).getTotalCount(); // 23
if (count ===0) { //do stuff } else { // do other stuff }
} );
} );
This worked great!
Thanks so much.