Hi,
I want to display a Button in a Repeater based on a boolean variable that is stored in a Collection field. If the field is checked, display the button, basically.
I read a couple of threads that recommend using $w and scope but can't really sort it out.
Some reference i gathered:
export function button1_click(event, $w) {
if(some condition is true) {
$w("#button1").show();
}
else {
$w("#button1").hide();
}
}
The $w scope selector parameter in the function is what makes Repeated Item Scope work.
$w('#myDataset').onReady(() => {
let itemObj = $w("#myDataset").getCurrentItem();
if (itemObj) {
$w('#button2'). link = itemObj........;
}
else {
$w('#button2').hide();
}
});
Many thanks, Mircea P.
Hi Mircea!
Your second bit of code is almost correct.
If the boolean field exists in your collection then you need to address it from inside the itemObj.
Meaning that if your field is called bool for example - your code would look like this:
$w('#myDataset').onReady(() => { let itemObj = $w("#myDataset").getCurrentItem(); if (itemObj.bool) { $w('#button2').show() } else { $w('#button2').hide(); } });
Let me know if it worked for you.
Doron.
try this...
$w.onReady(function () { $w("# myDataset").onReady(() => { $w("#repeater1").forEachItem(($w) => { const booleanValue = $w("# myDataset").getCurrentItem()._nameOfCollectionBooleanField //change this field name if (booleanValue === true ) { $w("#button2).hide(); }else{ $w("#button2).show(); } }) }) })