It seems the only way I can get an initial table row to be selected is to put a small time delay in inside the dataset.onReady function. I know that can’t be right. What am I doing wrong?
$w.onReady(function () {
$w("#themeDataset").onReady(() => {
setTimeout(function() {
const r_m = [6,7,8,9,10,11,0,1,2,3,4,5];
let today = new Date();
let m = r_m[today.getMonth()];
$w('#table1').selectRow(m);
}, 50);
})
});
The solution here is to use onReadyAsync() instead. This works for me:
$w('#dataset1').onReadyAsync().then(() => {
$w('#table1').selectRow(0);
})
I believe the cause of this issue is somewhere deep in the bowels of JavaScript. I remember reading something about it long ago but can’t seem to find it.
The reason I think this is that even with a setTimeout(func, 0) the error disappears. Though this is also not a complete answer as 4ms is JS’s shortest real interval.
Anyways enjoy the solution at least 