Scroll to last item in Repeater

Is there any way to scroll to the last container or item in the repeater.
I am not doing a query, is there any other way,

Thanks!
Ajith

1 Like

You can do:

$w("#repeater1").forEachItem( ($item, itemData, index) => {
if(index === $w("#repeater1").data.length - 1) {
$item("#container1").scrollTo();
}
})

Thanks J.D
It worked →

$w('#repeater1').forEachItem(($item, itemData, index) => {
 if (index === $w('#repeater1').data.length - 1) {                                         $item('#container1').scrollTo();
 }
 });

You’re welcome :slight_smile:

1 Like

@jonatandor35 Thanks for your answer…
can you help me in this, or should I create a new post?- >

I have a repeater connected to ‘dataset1’.
No: of items to display is set to ‘12’.
When the user scrolls down to the last container, of the repeater, it should show more items in the repeater.
Is there any way, that I can do, to achieve the above

Thanks!

Yes, please practice creating a new post for each new question. This helps organize content in the forum so others can search and find the answer quickly. It also prevents you from relying on a single person to answer each one of your questions every single time.

The forum is a community effort to assist others as a whole not to find a free private assistant. The majority of the people that are active in the forum are volunteering their time and knowledge ---- they are not employed by Wix so it is best practice to respect their time by posting a new question to see if anyone can genoursly weigh in on an answer when they have time to spare.

We also encourage you to pay it forward and answer other people’s questions if you know the answer to their problem.

For your new question, try out this tutorial: it explains the concept on how to auto load content.

2 Likes

@code-queen Thanks for your comment and also the video!!!

export function loaderStrip_viewportEnter(event) {
 let hasNext = $w('#dataset1').hasNext();
 if (hasNext === true) {
        $w('#loaderStrip').expand();
        $w('#loader').show();
        $w('#dataset1').loadMore()
        .then(() => {
            $w('#loader').hide(); 

        });
 
    }
 else { 
        $w('#loader').hide();
        $w('#loaderStrip').collapse();
    }
 
 
}
1 Like

I did this, but it’s not working for me. Which container do I need to scrollTo? I have a text in a container which is in a repeater item. I tried scrollTo’ing to the text container, and also to the repeater item, but neither worked. Any guidance is greatly appreciated.

Are you trying to scroll on the page, or within the container?

Within the container “Chat Container”. It’s a vertical scroll container.

Ok, I think that’s the problem. I’ve tried to do what you did, but without success. I’m pretty sure scrollTo() is only made to scroll the page, not scroll within a container, unfortunately.

1 Like

Any solution to achieve the results, like sticking the overflowed container scroll to bottom?