[Resolved] Code executes on second visit to page but not first!

Hi all,

I have a repeater connected to a dataset. I have code modifying how the elements of the repeater are displayed. The first page of the repeater displays as desired. When you click to page 2 (or 3, or so on), the repeater populates its elements but the code doesn’t visibly execute. If you click away from that page and return to it, the code has executed and everything is displayed as it should be. I’m guessing that the code is executing at the wrong time (I’m still really new to asynchronous code,) but I’ve included every onReady checks I could think of. Any ideas?

var myDataset;

 $w.onReady(() => {

    $w('#dynamicDataset').onReady(() => {
       ...
        Large();
    });
    $w("#pagination1").onChange((event) => {
        $w.onReady(() => {
            $w('#dynamicDataset').onReady(() => {
                Large();
            });
        });

    });
 });

 function Large() {
    $w('#sessions').onReady(() => {
        $w('#repeater1').forEachItem(($item, itemData, index) => {
            $item("#date").text = itemData.sessionDate.toLocaleDateString();
            $item("#session").text = "Session: " + itemData.session + " of " + itemData.currentPackage;
...    });

 }
1 Like

Not normally one to “bump” my own post, but any help would be deeply appreciated. Seems like this should be a simple oversight on my part. Really hoping someone can point it out to me…

In case anyone ends up having a similar issue, this was, as expected, a simple fix. The formatting needed to be done in an “onItemReady()” event handler.