[Solved] OnClick "Load More" for data in repeater

Hi All,

Appreciate the assistance!

Image reference :

Preface :
Above the “GET DEAL” button are two button icons that appear if a Boolean is marked as “true” in a dataset. The page loads 40 deals, then you can load an additional 40 by pressing a “load more” button at the bottom.

The part that works :
The code currently in place (below) works for the first 40 deals.

The issue :
Once the “load more” button is pressed, the following 40 items that appear are not processed by the code so the logic doesn’t get applied.

The code :
$w ( ‘#repeater1’ ). onItemReady ( ( $w , itemData , index ) => {
console . log ( itemData . superDeal );
if ( itemData . superDeal === true ) {
$w ( ‘#button2’ ). enable (); // show() doesn’t work
$w ( “#button4” ). enable ();
}
else { // forSale field is “no”
$w ( ‘#button2’ ). disable (); // hide() doesn’t work
$w ( ‘#button4’ ). disable ();
}
});

The ask :
How do I apply that code into a functional OnCLick() event so that when the “load more” button is pressed, it applies the code to the next batch of 40 items?

If you are using a DATASET (you do use a DATASET, don’t you?), then you just have to use the already given options of the DATASET-API…

https://www.wix.com/velo/reference/wix-dataset/dataset/loadmore

If you don’t use a DATASET → then you will have to generate your own load-More-function.

But i am not really sure if you need coding for that at all.
Normaly the dataset already provides such functionality in the PROPERTIES/OPTIONS of the DATASET itself.

All you have to do is to create abutton on your page (Load-More) and connect it inside the properties-panel in your wix-editor inside dataset-options-configuration.

But of course if you need it as code, you also can go the CODING-WAY.

Thanks for the reply.

The “Load More” button is connected to a dataset and does load more items upon pressing it. The issue is that the code provided in my post does not apply to the next batch of items once the “load more” button is pressed, only for the currently visible.

So I’m looking for a way to have the button run the snippet above after it loads the next batch of items.

Website below for reference. The issue can be seen by appending /testhome to the below site. You’ll notice the icons on some products but once you click on “load more”, every item afterwards has the icons from there on.

Solved :
I did not need to modify the “load more” button as originally assumed. Below is my updated code with the solution snippets marked in red.

Special thanks to Velo-Ninja. Although your reply to this thread was not helpful, I came across another thread where your contribution DID lead me to the solution.

$w.onReady( function () {
$w ( “#repeater1” ). onItemReady ( ( $w , itemData , index ) => {
console . log ( itemData . superDeal );
if ( itemData . superDeal === true ) {
$w ( “#button2” ). show ();
$w ( “#button4” ). show ();
}
else { // forSale field is “no”
$w ( “#button2” ). hide ();
$w ( “#button4” ). hide ();
}
});
});

For those interested in Velo-Ninja’s post that helped solve this issue, below is the snippet since my account is too new to post URL’s
(Maybe Velo-Ninja can find and update the URL. Site - wix dot com / velo/forum/coding-with-velo/onclick-load-more-for-data-in-repeater