I need help finishing off this code please. I want to check a database (linked to some dynamic pages) called prospects under the field called showMenu which will have a boolean entry - true or false.
If it's true I want a strip called menuStrip to show and if it's false for it not to. The error message is saying that 'item' is not defined.
Thanks for your help!!
@anthonyb thanks for this. The query is returning results. The menuStrip was ticked "collapsed on load" and I've unclicked that now, and have published but it's still not working right. I can check or uncheck the showMenu boolean in the database and it makes no difference to the menuStrip showing or not showing - it's always showing for every entry including "Shine".
Hi Clayton,
You will need to add some criteria in your query to specify exactly what record in prospects that you want to obtain data from. I'm using a facetious condition asking that the fullName field = "John Doe".
$w.onReady(function() { wixData.query("prospects") .eq("fullName", "John Doe") .find() .then( (results) => { if(results.items.length > 0) { let item = results.items[0]; if (item.showMenu === true){ $w("#menuStrip").show(); } } else { // nothing found } } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; }); });