I am trying to hide or show a button in a repeater. This is not working. Button appear in all or none. How to have it only in repeater that matches the condition. Thanks
$w.onReady(function () { $w("#dataset1").onReady(() => { $w("#repeater2").forEachItem(($item, itemData, index) => { // console.log($item("#text24").text +": " + $item("#text24").text.toString().includes("sponsor") ); if ($item("#text24").text.toString().includes("sponsor")) { $item("#container4").background.src = "wix:image://v1/0a7cf4_50add97aba4d47dcbdd0eaacb328e899~mv2.png/border-with-yellow-flowers-pv.png#originWidth=958&originHeight=487" $w('#button1').show(); } else { $w('#button1').hide(); } }); }); });
Agree. I’m just posting it in case someone comes looking for the same answer.
You can also try this
import wixData from 'wix-data'; import wixLocation from 'wix-location'; import wixWindow from 'wix-window'; $w.onReady(function () { $w("#repeater1").onItemReady( ($w, MyCollection) => { console.log(MyCollection.MyFieldCondition); if(MyCollection.MyFieldCondition === true) { $w("#myButton").label = "My message"; } else { $w("#openCampButton").hide(); } }); });
found the answer after reading docs. $item instead of $w