Collapse Load More Button Once All Items Have Been Loaded

Hi, I have a code for my “download more” button:

// Show or hide the ‘See More’ button based on whether or not there are more results waiting
export function SetSeeMoreButtonDisplay ( $w )
{
if ( $w ( “#dataset1” ). getTotalCount () > $w ( “#repeater1” ). data . length )
$w ( “#btnSeeMore” ). show ();
else
$w ( “#btnSeeMore” ). hide ();
}

This code works for me, BUT - one more question - I have add filter by categories of my repeater. What should be the code for “load more” button if I would like to hide it when there is the end of the list of exact category?
I mean if “Investment” category has 10 items - the “load more” button should hide at the end of this list, but if “Landing” category has 5 items, the “load more” button should hide after list of 5.
Would be grateful for any advice.

Hello.

If you are using a query to filter your collections based on category then you need to replace $w ( " #dataset1 " ). getTotalCount () with results . length . To learn more check out our API here: https://www.wix.com/corvid/reference/wix-data.WixDataQueryResult.html#length

Good luck!