Collapse empty elements in a repeater?

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();
}
});
});

Hi,

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();
}
});

I’m having an issue with a repeater at the moment, don’t know if it’s related.

I’m filtering with wix code but it’s not including all the fields in the filter (just a single filter on a boolean value in a dataset)

I think it has to do with the fact that the filter is happening “onReady”"

$w.onReady( function () {

let query = wixLocation.query;

if (query[‘product’] === ‘change’) {
$w(“#dataset1”).setFilter(wixData.filter()
.eq(“boolean”, true )
);

It works when the following query criteria is not true and i invoke it with similar code initiated by a button click event.

Any thoughts?

Hi,
What happens when the query condition is true?
Do you get any errors? maybe you should run the set filter in the dataset’s onReady .