How to hide "load more" button?

Hello, i have a “load more” button that is connect to a dataset. My question is how to hide this button when there is no results to show on the repeater?.. i’ve tried this code and it didn’t work :frowning: … any ideas ?

export function loadmorebutton_click(event) {
if ($w(“#dataset1”).getTotalCount() > $w(“#repeater1”).data.length)
$w(“#loadmorebutton”).show();
else
$w(“#loadmorebutton”).hide();
}

Hey there!


export function loadmorebutton_click(event) { 
    let hasNextPage = $w("#myDataset").hasNextPage(); // true
    if(hasNextPage)  {   
       $w("#loadmorebutton").show();  
    } else { 
          $w("#loadmorebutton").hide(); 
    }
}

Try this one, this will check if your dataset has another page when you have moved to the next set. Remember that if it doesn’t work maybe the dataset is not ready for usage and you need to wrap it in the onReady function as well.

Hello # Andreas Kviby :slight_smile: thank you so much for your reply, it didn’t work actually, how to put it onReady ? also i would like to ask u something, whenever i run search on the dataset the loadmore button onClick shows all items instead of loading more items of the filtered items, How to fix this also please ? :slight_smile:

Oh btw i have only 1 page that loads all items, no next page.