Hi,
according to WIX tutorial here , i tried to encode search and other filters on my website. I managed to do the search filter (iTitle) and the dropdown filter (iProjects). But I wanted to add another dropdown filter (iRok), which is not working.
Can you please see the code where I’m making a mistake? I will need to add another filter there - sort by concepts. But I think I can do it when I will see the right code for iRok. It is better for me t o fix the error in the code directly than to write the procedure.
The code is here:
import wixData from “wix-data” ;
$w.onReady(() => {
loadKategorie()();
});
let lastFilterTitle;
let lastFilterKategorie;
let lastFilterRok;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value, lastFilterKategorie);
}, 500 );
}
export function iProjekty_change_1(event, $w) {
filter(lastFilterTitle, $w( ‘#iProjekty’ ).value);
}
export function iRok_change(event, $w) {
filter(lastFilterTitle, $w( ‘#iRok’ ).value);
}
function filter(title, kategorie, rok) {
if (lastFilterTitle !== title || lastFilterKategorie !== kategorie) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains( ‘title’ , title);
if (kategorie)
newFilter = newFilter.contains( ‘kategorie’ , kategorie);
if (rok)
newFilter = newFilter.contains( ‘rok’ , rok);
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterTitle = title;
lastFilterKategorie = kategorie;
lastFilterTitle = rok;
}
}
function loadKategorie() {
wixData.query( ‘Kategorie’ )
.find()
.then(res => {
let options = [{ “value” : ‘’ , “label” : ‘all kategorie’ }];
options.push(…res.items.map(kategorie => {
return { “value” : kategorie.title, “label” : kategorie.title};
}));
$w( ‘#iProjekty’ ).options = options;
});
}
function loadRok() {
wixData.query( ‘Rok’ )
.find()
.then(res => {
let options = [{ “value” : ‘’ , “label” : ‘all rok’ }];
options.push(…res.items.map(rok => {
return { “value” : rok.title, “label” : rok.title};
}));
$w( ‘#iRok’ ).options = options;
});
}
Page picture with info:
Thanks in advance for your help
Best
Sabina