I’m trying to disable a button or collapse text field when respective key field in a collection is empty. I tried using this code to check if a document was in the field. If empty, i wanted the button to disable itself. BTW I tried loading the page with the button disabled on loading (unchecked the box), and then enabling if the field was not empty too. I tried a lot, but maybe I’m missing a key component/idea? Maybe I’m in global scope vs item scope? Trying to grasp the concept. Thank you in advance.
$w.onReady(() => {
$w(“#whatsNewData”).onReady(() => {
// Gets the current item properties and stores them in a variable called item const item = $w(“#whatsNewData”).getCurrentItem();
// Checks if the current item has a value in the “document” field if (!item.document) {
// Collapses the download button if there is no value for “document”
$w(“#rankingsBtn”).disable();
}
});
});
If you are talking on handling repeater element based on the data of the item you should use the:
$w(“#myRepeater”).onItemReady( ($w, itemData, index) => {
if (! itemData.document) { // based on your “empty status” you need to change this line.
$w(" #rankingsBtn ").disable();
}
});