Clearing repeater data

Hi. I have an irritating little problem that I think should be easy to solve.
This problem shows up while in Preview mode.
I have created a repeater using data from a query.
The repeater stays hidden until a user selects an item from my page.
Then the repeater appears with the data, based upon the user’s choice.
The problem is, that for several seconds the repeater displays what appears to be
the latest data entered into the database, before finally displaying the results of the query.

If the user no longer wishes to view that repeater, it is hidden. But when they make another choice, from the page, the repeater reappears, but with the old data from the old query, for several seconds, again, before displaying the data from the new query.

Here is a rough approximation of the query I am using.

{
var julday = event.data;

          wixData.query("mydataset") 
             .ge("title", "beginningcriteria")) 
             .le("title", ("endingcriteria") 
             .ascending("title") 
             .find() 
             .then( (results) =>  
                { 
                   if (results !=="") 
                   { 
                      let d_item = results.items; 
                      $w('#repeater2').data = d_item; 
                   } 
                }); 
             $w('#repeater2').show(); 
      } 

I tried clearing the data in #repeater2 by using this line
$w(‘#repeater2’).data=null
but that results in an error.
My question is:
How can I get the repeater to display the results of the query, and only the query and not data based on previous queries?

Hi,
instead of:

$w('#repeater2').data=null

do:

$w('#repeater2').data=[]

Eli, thank you for your response. However, your idea did not solve my problem. My repeater displays some unwanted dataset before going blank, then coming back with the correct set of records based on the query. Seems to take about a second and a half to make the transition.

Hi thesaurusrex,

Did you happen to solve this issue? I’ve been facing the same thing and attempted both the clearing to null and the empty array with no luck.

Hi,
Can you please share a link to your sites and specify the name of the page?
Roi.

I recommend you hide the repeater if there is no data to view to stop it from showing default Wix items and when you cleared it and new records is rendered show it again. Reset with .data = []; or use a query with no results :wink:

Seems I missed that reply

@Roi,
Our site is cravehome.co and the page I’m having issue issue with is called cookdashboard.

@Andreas,
I kinda do what you recommend. The repeater is hidden by default and displayed, supposedly, after data was loaded into it. Before populating the repeater I also have a statement to clear the data.
My code goes a bit like this:

$w.onReady( function () {
$w(‘#repeater1’).data=[];
CallServiceToGetData
.then( repeaterData => {
$w(“#repeater1”).onItemReady(($w, itemData, index) => {
populateRepeaterWithData
}),
$w(“#repeater1”).data = repeaterData;
$w(“#repeater1”).show()
})
}
}

Sadly it doesn’t help.

PS: I’ve just noticed I think I took one of your tutorials, Andreas, on WiXShow on this topic (integrating with airtable). Was really interesting.

I’m experiencing the same thing on my published site. Anyone come across anything that they think causes this behavior?