Wix Code | Youtube Video Question

I have been following the instructions on the Youtube Video titled ‘Wix Code | How to Create a Search for Your Database’ to link a search bar and dropdown to my Wix data in my Database.

See video link here: Wix Code | How to Create a Search for Your Database - YouTube

I followed the video to a T, and found that my ‘All Continents’ dropdown does not work (everything else works great). I believe he made an error in the video, and there is an error in his code.

Has anyone else had this problem? If so, how could I modify his code to fix it?

Thank you,
Josh

I forgot to include the code:

import wixData from “wix-data”;

$w.onReady(() => {
wixData.query(‘country’)
.find()
.then(res => {
let options = [{“value”:‘’,‘label’:‘All Countries’}];
options.push(…res.items.map(country => {
return {‘value’: country.title, ‘label’: country.title};
}));
$w(‘#dropdown1’).options = options;
});
});

let lastFilterTitle;
let lastFilterCountry;

let debounceTimer;
export function ititle_keyPress_1(event, $w) {
if(debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#ititle’).value,lastFilterCountry);
}, 200);
}

function filter(title,country) {
if (lastFilterTitle !== title || lastFilterCountry !== country) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘country’,title);
if (country)
newFilter = newFilter.eq(‘country’,country);
$w(‘#dataset1’).setFilter(newFilter);
lastFilterTitle = title;
lastFilterCountry = country;
}
}

export function dropdown1_change(event, $w) {
filter(lastFilterTitle, $w(‘#dropdown1’).value);
}

Hi Josh!

Try to take a look into this thread.
I believe it will answer your question.

Best of luck!
Doron. :slight_smile: