Hi,
I run the following code in my OnReady function and it is working fine...
$w.onReady(function () {
$w("#datasetMembersOnly").onReady(() => {
$w("#rptMembers").forEachItem(($w, itemData, index) => {
if (itemData.approved === "1") {
$w("#boxName").style.backgroundColor = "#FFFFFF";
$w("#boxCompany").style.backgroundColor = "#FFFFFF";
$w("#boxJobTitle").style.backgroundColor = "#FFFFFF";
$w("#boxEmailAddress").style.backgroundColor = "#FFFFFF";
$w("#btnApprove").hide();
$w("#btnDisable").show();
} else {
$w("#boxName").style.backgroundColor = "#7FCCF7";
$w("#boxCompany").style.backgroundColor = "#7FCCF7";
$w("#boxJobTitle").style.backgroundColor = "#7FCCF7";
$w("#boxEmailAddress").style.backgroundColor = "#7FCCF7";
$w("#btnApprove").show();
$w("#btnDisable").hide();
}
console.log(itemData.approved)
});
});
console.log("on ready")
});
However, when I run the same code in an OnClick event, it is not returning the same results...
export function btnAllMembers_click(event) {
$w("#datasetMembersOnly").onReady(() => {
$w("#rptMembers").forEachItem(($w, itemData, index) => {
if (itemData.approved === "1") {
$w("#boxName").style.backgroundColor = "#FFFFFF";
$w("#boxCompany").style.backgroundColor = "#FFFFFF";
$w("#boxJobTitle").style.backgroundColor = "#FFFFFF";
$w("#boxEmailAddress").style.backgroundColor = "#FFFFFF";
$w("#btnApprove").hide();
$w("#btnDisable").show();
} else {
$w("#boxName").style.backgroundColor = "#7FCCF7";
$w("#boxCompany").style.backgroundColor = "#7FCCF7";
$w("#boxJobTitle").style.backgroundColor = "#7FCCF7";
$w("#boxEmailAddress").style.backgroundColor = "#7FCCF7";
$w("#btnApprove").show();
$w("#btnDisable").hide();
}
console.log(itemData.approved)
});
});
console.log("all members button clicked!")
}
It seems to skipping the else statement and only returning the items to be approved?
Can anyone offer any help?
Many thanks :)
Hi Steve, this actually has public access at the moment (but will become password protected)
The page is https://www.markhatterassociates.co.uk/approve-members
I really appreciate your time and effort, thank you :)
Rachel
Hi Rachel:
Is the problem on the Members Only page of this site: https://www.markhatterassociates.co.uk?
If so then it may be tough for a mere mortal to debug without more privileged access. If you can post the page that the code is on that will help.
If it is privileged then I can help but you would need to make me a contributor unless you want to wait for a Wix person to hit this link.
Steve