Hi all,
My website uses one database to populate different repeaters on the same page which are filtered with code.
When the site loads, first all the content except the repeaters load, then the repeaters load with NO filtering (showing all items), and THEN each repeater updates to show only its' properly filtered content.
Any tips on how to make this process faster? Can I filter the repeaters before the page is ready somehow so that the user doesn't see incorrect database items before the filtering happens?
Here is my page code:
import wixData from 'wix-data';
$w.onReady(function () {
//TODO: write your page related code here...
//featured events repeater
$w("#dataset1").onReady( () => {
let d = new Date(); // get today's date
wixData.query("events")
.include("venue")
.ge("date", d)
.eq("approved", true)
.eq("featured", true)
.ascending('date')
.limit(3)
.find()
.then((results) => {
$w("#featuredRepeater").data = results.items;
});
});
//upcoming events repeater $w("#dataset1").onReady( () => { let d = new Date(); // get today's date wixData.query("events") .include("venue", "category") .ge("date", d) .eq("approved", true) .ascending('date') .limit(10) .find() .then((results) => { $w("#todaysEventsRepeater").data = results.items; }); }); });
adding .then clause after adding you filter statement does the job.
See this link --> https://www.wix.com/velo/forum/coding-with-velo/repeater-loads-before-it-is-filtered-properly
$w("#dataset1").setFilter(wixData.filter().ne("gender",firstItem.gender) ) .then(()=>{$w("#repeater1").show();})
Did you ever find a solution? I see the same behavior.
I too, am having this issue, as I have to use the corvid filtering to implement an OR condition.
$w.onReady(function () { $w("#MyData").setFilter(wixData.filter() .contains("street", "Street 1") .or(wixData.filter().contains("street", "Street 2")) ) });
Loaded into the page code.
The unfiltered version loads in before it is replaced with the filtered version.
Hello Stacey,
The worst case scenario is that you hide the repeater until the filtering process is done and then show it when it is done filtering.
I would suggest filtering through the dataset and not through code as it will make it faster as well.
Can you post here the code for how you filter the dataset, maybe it can be optimized.
Thanks,
Majd