How to expand a repeater after all the contents are loaded?

Hi Experts,

I have some trouble loading all the contents in my repeater before it appears. My repeater appeared before all the contents are loaded, and I am able to see the contents changes. I wanted my repeater to appear with the correct information, instead of appearing followed by loading of contents.

Here is my code:

function filterReview() {
 let n = $w('#nDataset').getCurrentItem();
        $w("#reviewsDataset").setFilter(wixData.filter()
        .contains("nId", n._id))
        .then ( () => {
            reviewsPNameImage();
            reviewsStarsRating();           
            reviewsDate();
            $w('#repeater1').expand(); 
        })  
}

What should I change to make sure the repeater appear with the right contents?

Thank you in advance!

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

Hi Yisrael,

Thanks for helping again!
Here’s my URL, it is a test site:

The basic logic is flawed. The onItemReady() function is called by the repeater when its contents have changed. Having more than one onItemReady() function will cause unpredictable results.

Based on what my understanding of you code, you would be better of without using a dataset and should do a filtered query directly on the collection. You’ll have better control on collapse/expand of the repeater, as well as more control over the contents of the repeater items.

Good luck,

Yisrael

HI Yisrael, thank you very much for helping!