Hello again Yisrael,
So I looked at the example but I’m afraid I didn’t understand how to implement it 100%. In the example there is a different method used to filter.
Your example filter method is coded like this:
export function iContinent_change(event, $w) {
filter(lastFilterTitle, $w('#iContinent').value);
}
function filter(title, continent) {
if (lastFilterTitle !== title || lastFilterContinent !== continent) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('articleTitle', title);
if (continent)
newFilter = newFilter.contains('continent', continent);
$w('#dataset1').setFilter(newFilter);
lastFilterTitle = title;
lastFilterContinent = continent;
}
I’m afraid I’m not familiar with this way of setting the filter. I instead use this method:
export function filterFordonstyp_change(event) {
$w('#bilarDataset').setFilter(wixData.filter().eq('aktiv', true)
.contains('fordonstyp', $w('#filterFordonstyp').value)
.contains('marke', $w('#filterBrand').value)
.contains ('drivmedel', $w('#filterPower').value)
.contains('vaxellada', $w('#filterGearSystem').value)
.between('saljpris2', parseFloat($w('#filterPrisfran').value),
parseFloat($w('#filterPrisTill').value))
.between('fordonsar', parseFloat($w('#filterYearFrom').value),
parseFloat($w('#filterYearTo').value))
.between('mital', parseFloat($w('#filterMilesFrom').value),
parseFloat($w('#filterMilesTo').value))
)
.then((results) => {
console.log('Dataset has been filtered');
if ($w("#bilarDataset").getTotalCount() === 0) {
$w("#txtNoResult").show();
$w("#carProductList").data = results.items;
} else {
$w("#txtNoResult").hide();
}
})
.catch((err) => {
console.log(err);
});
$w('#carProductList').expand();
}
The code looks exactly the same for all other onChange events for every drop down on the page. How can I implement the “remember function” to my code? Or do I need to rebuild the code so it uses the same method as in your example?
Your code looks much cleaner and simpler than mine, however, I’d prefer if I didn’t have to redo the entire code if possible.
Many thanks in advance!