I had the loadMore() function working but it isn’t now.
export function box1_viewportEnter(event) {
$w("#dataset1").loadMore()
.then( () => {
console.log("Done loading more data");
} );
}
Please help!
I had the loadMore() function working but it isn’t now.
export function box1_viewportEnter(event) {
$w("#dataset1").loadMore()
.then( () => {
console.log("Done loading more data");
} );
}
Please help!
Check here → dataset API
A dataset needs to load its data before you call its loadMore() function. Usually a dataset finishes loading a short time after the page it is on finishes loading. loadMore() inside the page’s onReady() event handler, the dataset might not be ready yet.
Try this →
export function box1_viewportEnter(event) {
$w('#dataset1').onReady(() => {
$w("#dataset1").loadMore()
.then( () => {
console.log("Done loading more data");
});
});
}
Although your words are correct, but your code is NOT, this is not the right way to write the code, you can’t write the page’s onReady() function inside an event handler, it should be written on the top scoop, and the event handler inside it, not the opposite, and for that matter, you need to use dynamic event handler instead of this static one. Here’s how:
$w.onReady(() => {
$w('#dataset').onReady(() => {
$w('#box1').onViewportEnter((event) => {
$w('#dataset').loadMore();
})
})
})
TIP: The event handler is triggerd to load more dataset items, so it also needs to be inside the dataset’s onReady() function.
Thanks! It is now gooooood! Thanks!
Oops! Thanks for the
@ajithkrr you’re welcome
You’re welcome Arthur, happy coding.