Dataset onReady not running

I have a couple of datasets on a page displaying data. And when there is no data, it shows a message saying nothing is there.

It is supposed to check in the onReady function for the datasets bu they don’t seem to be running. Everything is setup correctly and connected.

wix dataset onReady not working

It was working fine yesterday on my laptop with Firefox but not working today on Chrome.

This is my code. It is pretty simple and the logs don’t show in the console or in the site monitor which is why I don’t think the onReady functions are running for the datasets.


export function academicData_ready() {
    console.log("acadmicData ready");
 if ($w("#academicData").getTotalCount() === 0) {
        $w("#academicRepeater").collapse();
        $w("#noAcademic").show();
    }
}

#bug #dataset

Try:

$w.onReady( function() {
    $w("#academicData").onReady(() => {
        //put the rest of your code here
    })
})

Yeah I had it like that at first but it makes it difficult to read the code. The way I currently have it setup, it should be running. It runs maybe once every like 10 refreshes. The same thing was happening when it was in the page onReady function.

@patrick
" To call getTotalCount() as soon as possible after a page loads, use the dataset’s onReady() function inside the page’s onReady() event handler to ensure that both the page and the dataset have finished loading. "
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#getTotalCount