Repeater Display Issues

Hello,

I am seeing a very strange issue with a repeater in both my editor and my live site. I am populating the repeater with code using its data property. The data I populate the repeater with is the results of a search query. See the code here:

query.find().then( (results) => //run the query on the listings collection
{
var matchingListings = results.items; //get the array of items that match the query
numMatches = matchingListings.length; //get the number of listings that match the query
$w(‘#loadingBox’).collapse(); //collapse the loading box
if ( numMatches > 0 ) //if there is at least one listing that matches the query
{
$w(‘#listingsRepeater’).data = matchingListings; //set the repeater data
$w(‘#listingsRepeaterBox’).expand(); //expand the listings repeater box
}
else //if there are no listings that match the query
{
$w(‘#noMatchesBox’).expand(); //expand the no matches box
}
});

This allows me to search different terms and get different results, changing the data in the repeater. For whatever reason, I can only change the data in the repeater twice before the repeater disappears completely. If you go to https://www.reddyrealtor.com/search-for-a-home
and plug in “r” as the search term and hit search you can replicate the problem. It will work fine if you search it once, and then again, but the third time it will break. Please help if you know what the issue is! Thanks in advance!

-Eric

The problem does not happen for me. I’ve tried it repeatedly and the repeater always appears.

Hi Yisrael,
I was able to fix the problem. The issue was two fold. First, I was clearing the repeater data by setting it to an empty array just before I populated it with new data. For some reason this was causing an error. Once I changed that it worked better. However, after changing search terms four or five times, the repeater would display, but just with the generic template info and not with the new data. This appeared to be a robustness issue with the onItemReady function for the repeater. Once I switched to forEachItem the issue went away.
-Eric

1 Like