I have a large repeater on my website, with the ability to click individual items which takes you to the individual item page. Once the user is finished on the individual item page - they hit back and they return to the repeater page - but their filter settings have reset - forcing them to input them again.
Is there a way for the repeater to REMEMBER their input so they don’t have to re-do their selection every time? It’s very tedious.
1 Like
Have the item open in a new page to not only save their selection but also save their place on the page.
Otherwise, you need to add extra code to your filter function to save their answer in storage as they select their filters.
If you did not code your filters, you will need to do it now in order to implement some code to the onChange of the elements.
https://dev.wix.com/docs/velo/articles/getting-started/storage-api
Hi there!
Thanks so much for this solution. Good to know it is possible. However I lack the skills to be able to execute it!
Another option could be to place the filter value in the url to support the back button without having to use memory and make the filtered url shareable as well.
import wixLocationFrontend from 'wix-location-frontend';
// Automatically apply the filter upon load
$w.onReady (function () {
$w('#dropdownfilter').onChange(() => {
filterProcesses();
})
// Get the current query parameters
let query = wixLocationFrontend.query;
// Check if the 'q' parameter exists and run the filter automatically on the page
if (query.q) {
// Set the dropdown value to the query parameter
$w("#dropdownfilter").value = query.q;
let filter = wixData.filter();
filter = filter.eq('dataSetFieldYouWantToFilterOn', query.q);
$w('#dynamicDataset').setFilter(filter);
}
});
export function filterProcesses() {
let filter = wixData.filter();
filter = filter.eq('dataSetFieldYouWantToFilterOn', $w("#dropdownfilter").value);
$w('#dynamicDataset').setFilter(filter);
// Get the selected value from the dropdown
let selectedValue = $w("#company").value;
// Check if a value is selected
if (selectedValue) {
// Construct the query parameter
let queryParam = { "q": selectedValue };
// Add the query parameter to the URL
wixLocationFrontend.queryParams.add(queryParam);
} else {
// If no value is selected, remove the query parameter
wixLocationFrontend.queryParams.remove(["q"]);
}
}