multiple selection tag filter 🚀
Cuisine:
Location:
Cost:
16 items found
Gelato
Italian
$
50
Risotto
Italian
$
50
Bœuf bourguignon
French
$
50
Soupe à l’oignon
French
$
50
Chips & Pastry
Italian
$
50
Yellow Cab
Italian
$
50
Ravioli
Italian
$
50
Pizza
Italian
$
50
Cassoulet
French
$
50
Paris Spaghetti
French
$
50
Potato House Diner
Italian
$
50
Lasagna
Italian
$
50
Chocolate soufflé
French
$
50
Coq au vin
French
$
50
Rolled & Scrambled Eggs
French
$
50
The Roasted Chicken
French
$
50
import wixData from 'wix-data';
$w.onReady(function () {
$w("#cuisineTags, #locationTags, #costTags").onChange(function () {
search();
});
function search() {
let filter = wixData.filter();
let cuisIdx = $w("#cuisineTags").selectedIndices;
let locIdx = $w("#locationTags").selectedIndices;
let costIdx = $w("#costTags").selectedIndices;
let cuisVal = $w("#cuisineTags").value;
let locVal = $w("#locationTags").value;
let costVal = $w("#costTags").value;
if (cuisIdx.length > 0 || locIdx.length > 0 || costIdx.length > 0) {
filter = filter.hasAll("cuisine", cuisVal)
.and(filter = filter.hasAll("location", locVal))
.and(filter = filter.hasAll("cost", costVal))
$w("#dataset1").setFilter(filter)
.then(count)
} else {
$w("#dataset1").setFilter(filter)
.then(count)
}
$w("#button1").onClick(function () {
$w("#cuisineTags, #locationTags, #costTags").value = undefined;
$w("#dataset1").setFilter(wixData.filter()).then(count);
});
}
//COUNT ITEM
function count() {
let count = $w("#dataset1").getTotalCount();
if (count > 0) {
$w("#countText").text = `${count} items found`;
} else { $w("#countText").text = `No item found`; }
return count;
}
$w("#dataset1").onReady(function () {
count();
});
});