Conditional change of a button label in a repeater

I have 100+ Course listings in a 10-item repeater connected to a dataset and I want to check each item and, if that item’s cStatus field indicates it is a bookable course, change the button label of that item to read: “bookable”.

$w("#dataset1").onReady(()=> {
    $w("#repeater1").forEachItem( ($item, itemData, index) => {
      if(itemData.cStatus === "BOOK"){
         $item("#button104").label = "Bookable"
       }
    });
});

This code almost works. It scans (and if bookable) changes the button label of the 10 items that appear in the repeater on page load. But it does nothing for the repeater items that appear after the “show more” button is pressed or a data filter is applied.

I need code that either a) reads thru and updates the entire dataset on page load, or updates the repeater as its contents change. Thought of adding an onChange() event handler to repeater1 or its filter buttons, but don’t see that option for repeaters.

You can do this more easily by using onItemReady, as that runs every time a new item is added (this means it’s great when used on a repeater that is connected to a dataset/you feed content through code, but will not work on re-made repeaters). This also means you don’t need the .onReady on the dataset

    $w("#repeater1").onItemReady( ($item, itemData, index) => {
      if(itemData.cStatus === "BOOK"){
         $item("#button104").label = "Bookable"
       }
    });
1 Like

Works as advertised! Thank you.