Hi there,
Can someone tell me where I went wrong? I added a search button and a dropdown menu(Location) but the dropdown menu does not function for some reason…
import wixData from ‘wix-data’ ;
$w . onReady (() => {
loadlocation ();
});
let lastFilterjobTitle ;
let lastFilterlocation
let debounceTimer ;
export function iTitle_keyPress ( event , $w ) {
if ( debounceTimer ) {
clearTimeout ( debounceTimer );
debounceTimer = undefined ;
}
debounceTimer = setTimeout (() => {
filter ( $w ( ‘#iTitle’ ). value , lastFilterlocation );
}, 500 );
}
export function iLocation_change ( event , $w ) {
filter ( lastFilterjobTitle , $w ( ‘#iLocation’ ). value );
}
function filter ( jobTitle , location ) {
if ( lastFilterjobTitle !== jobTitle || lastFilterlocation !== location ) {
let newFilter = wixData . filter ();
if ( jobTitle )
newFilter = newFilter . contains ( ‘jobTitle’ , jobTitle );
if ( location )
newFilter = newFilter . contains ( ‘location’ , location );
$w ( ‘#dataset13’ ). setFilter ( newFilter );
lastFilterjobTitle = jobTitle ;
lastFilterlocation = location ;
}
}
function loadlocation ( ) {
wixData . query ( ‘location’ )
. find ()
. then ( res => {
let options = [{ “value” : ‘’ , “label” : ‘All Location’ }];
options . push (… res . items . map ( location => {
return { “value” : location . jobTitle , “label” : location . jobTitle };
}));
$w ( ‘#iLocation’ ). options = options ;
});
}
Any help will be highly appreciated