Disabling one button within a repeater of many

I’m trying to create an alphabetical menu for my database of interviews. I’m using repeaters and it’s working fine–except for one thing. See my screenshot below: we’re on page E, displaying all interviewees with last names beginning with ‘E’, we got there by pressing the ‘E’ button circled in the navigation. But now that we’re on this page (which is a dynamic collection page), I want the ‘E’ button to be disabled (and then reenabled if I click on a different letter). How can I do that please? (And many thanks for your great service).

Hi,
My suggestion is to use onItemReady method of repeater’s element.
It should similar to this function:

$w("#myRepeater").onItemReady( ($w, itemData, index) => {
  let charOfThisPage = $('#textInRepeater').text.slice(0,1);
  if (charOfThisPage === itemData.lastname.slice(0,1)) {
    $w('#myButton').disable();
  }
});

Good luck!
Roi.

2 Likes

Thanks v much Roi.
How can I define the $(’ #textInRepeater ')?

It’s the label of a button…

Hi,
If it’s a button element you can use:
let charOfThisPage = $(’ # yourButton’).label.slice(0,1);
Good luck!
Roi.

Big thanks Roi but it’s still not working for me. Here’s my code:

$w(“#repeaterAB”).onItemReady( ($w, itemData, index) => {
let charOfThisPage = $(‘#button14’).label.slice(0,1);
if (charOfThisPage === itemData.title.slice(0,1)) {
$w(‘#button14’).disable();
}
});

But when I try to run it I get a red warning telling me $ is undefined. See the screenshot:

Any ideas?

And here’s the screenshot…

You must use $w not only $

I’ve tried that!
But will try again. Thanks though…

When I use $w the error message is removed but the code still doesn’t work. This is the message I then get in the developer’s console:

It should be inside $w.onReady scope