HI guys, I want to display two images depending on the boolean being ticked or not. My code shows no errors but just won’t work. It is an accommodation site and I wish to show grey icons if no amenities or black if there is. The field is a boolean in my databse and called pool.
ANy ideas?
import wixData from ‘wix-data’;
$w.onReady( () => {
$w(“#dataset1”).onReady( () => {
let items = $w(“#dataset1”).getCurrentItem().pool;
if (items===‘true’){
$w(“#shape4”).show();
}
else{
$w(“#shape5”).show();
}
} );
});
You definitely need to use the key, so pool is the right way to go.
If it’s still not working for you, you’ll need to do some more serious debugging. You can start by adding some console.log() lines to your code to see if the information you’re retrieving from the dataset is what you expect. If you’re a little more familiar with debugging, you can use your browser’s debugger to get even more information.
hmm I have no idea how to do that and reading the articles looks out of my depth, is it possible for you to inspect my site to see if there is some easy fix?
Okay, I’ve taken a look at your site and now I have the full picture.
You are using a repeater to show your data, which is great, but complicates things a bit. Basically, because you are connecting data to the repeater using a dataset and you want to modify how the repeated items look using code you need a bit of a hack.
This is what you need to do (let me know if you want information about why you need to do all of this):
Add a text element to your repeated items.
Connect the text element to the pool field using the dataset already on the page.
Change the ID of the text element you just added to hasPool using the Properties panel.
Hide the text element you just added using the Properties panel.
Indeed, Hannah, you shouldn’t need the text field anymore. At the time of the original posting there was a bug that we were working around by adding a text field. It is my understanding that the bug was fixed quite some time ago.
Thanks, but i’m still lost on how to check if the current user(_id) has filled out the Name field, any ideas?
I know it’s a basic question but i can’t find how to do it.