Hi,
I am novice to wix and coding. I have two drop down filters that are connected to a dataset. One filter helps select the “genre” of paintings and the other “availability” (available, sold and on hold). Both work together for most of the options except for "All’. The "All’ Option in the “genre” dropdown or “availaibility” dropdown does not work individually or together and does not not bring back all the items I have searched this on the net and have found some discussions on resetting filters but havent been able to get results from those. Please advise and help on how i can make the "All’ Option work. Thank you in advance.
My code, which may be “totally wrong” is as follows:
import wixData from “wix-data”;
$w.onReady(() => {
});
let lastFilterGenre;
let lastFilterAvailability;
let debounceTimer;
export function dropdown1_change(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#dropdown1’).value, lastFilterAvailability);
}, 200);
}
export function dropdown2_change(event, $w) {
filter(lastFilterGenre, $w(‘#dropdown2’).value);
}
function filter(genre, availability) {
if (lastFilterGenre !== genre || lastFilterAvailability !== availability) {
let newFilter = wixData.filter();
if (genre)
newFilter = newFilter.contains(‘genre’, genre);
if (availability)
newFilter = newFilter.contains(‘availability’, availability);
$w(‘#paintingsDataset’).setFilter(newFilter);
lastFilterGenre = genre;
lastFilterAvailability = availability;
}}