Hide/show button by dataset values?

Hello!
this forum helps me much! And i hope it will do also this time.
I want to place a button, wich rendering should be controlled be some boolean values from a dataset.

This code is the only one that seems to react, but hide the button all the time;

$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => {
let items = $w(“#dynamicDataset”).getCurrentItem();
if (items[“#Button”]) {
$w(“#button1”).show(); }
else $w(“#button1”).hide();
});
});

Thanks for your help!

You forgot the curly brackets:
else { $w(" #button1 ").hide(); }

  • a field key can’t be “#Button”. You probably used a field label instead of field key.

J. D. thank you for your help!
But it still dont work, still dont show the button. Also try it with a renamed field key…

// Besuchen Sie für die komplette API-Dokumentation einschließlich Codebeispielen http://wix.to/94BuAAs
$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => {
let item = $w(“#dynamicDataset”).getCurrentItem();
if (item[“bool”]) {
$w(“#button1”).show(); }
else { $w(“#button1”).hide(); }
});
});
//TODO: write your page related code here…

Your code looks fine, so the problem is probably somewhere else. Maybe you used the wrong property names, field key name. Maybe you didn’t set database permission or forgot to syc the collection. I can’t say. You should try to locate the issue. What do you see in the code console, when you add console.log(item); ? What happens if you reverse the condition, and use if(!item.bool) ?is it shown all the time? Try to investigate.