I wrote a simple piece of code I use to filter datasets by URL query parameters, in order to populate a gallery with only certain items from a collection:
let queryValue = wixLocation.query;
$w('#myDataSet').setFilter(wixData.filter().contains('_id', queryValue.value)
This worked great unless I was navigating to the same page and only changing the query value. I fixed that by adding another line of code:
wixLocation.onChange( (location) => {
let queryValue2 = wixLocation.query;
$w('#myDataSet').setFilter(wixData.filter().contains('_id', queryValue2.value));
} );
With both of those bits of code the code then works fine no matter how the user gets to the page …
However, no matter which code is running, for a brief moment the first item in the dataset loads regardless of the filter that has been applied, which looks terrible …
I have a stopgap fix in place (hiding the gallery attached to the dataset, and fading it in with a delay); but I would like a better solution if one exists …
I have looked into using the Rendering API to prevent this, but I can’t seem to make that work …
Anyone have a solution?