Hello there,
today i were trying to do some filtering but with switch and multiple buttons
the logic is as follow
- at start shows all staff
- if button is onClick then it will filter as per button pressed
- if switch is been checked (selected), then filter per checked
-if switch is checked then button pressed, then filter by both (switch and button)
Switch between 2 location (filter by location — works)
then if button is clicked filter again (does not work!)
my code
om
import wixData from 'wix-data';
$w.onReady(function () {
});
export function switch1_change(event) {
let Mawaleh = !$w('#switch1').checked;
let Bousher = $w('#switch1').checked;
if (Bousher) {
Filtering("Bousher");
}
if (Mawaleh) {
Filtering("Mawaleh")
}
}
export function Administrators_click(event) {
Filtering("Administrators");
}
export function Management_click(event) {
Filtering("Management");
}
export function Teachers_click(event) {
Filtering("Teachers");
}
function Filtering(bool, click) {
let location = bool;
let section = click;
console.log(location);
console.log(section);
if (location === "Bousher") {
$w('#teamDataset').setFilter(wixData.filter().eq("shortDescription", "Bousher").eq("longDescription", section));
}
if (location === "Mawaleh") {
$w('#teamDataset').setFilter(wixData.filter().eq("shortDescription", "Mawaleh").eq("longDescription", section));
}
}
any help or any suggestion please