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