I have create the database collection also link the dataset to the repeater as well as dynamic pages, so now i am trying to create a search bar to search keywords as well as a filter of country for the database named “employerjobposting” on page “job seeker”. My website link:
https://georgemikhail9.wixsite.com/gmkpartners
- First I use user input - text and drop down to create the search bar, add “search” button: I don’t know if this is correct, as i don’t know how to add the search bar…
- Then I changed properties to “iTitle” and “iCountry” respectively
- Create the database of “Countries” to add all drop down listed countries
- Copy paste tutorial coding to my page and change certain content (I have no coding knowledge) as follows:
import wixData from “wix-data”;
$w.onReady(() => {
loadCountries();
});
let lastFilterTitle;
let lastFilterCountry;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#iTitle’).value, lastFilterCountry);
}, 500);
}
export function iCountry_change(event, $w) {
filter(lastFilterTitle, $w(‘#iCountry’).value);
}
function filter(title, country) {
if (lastFilterTitle !== title || lastFilterCountry !== country) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘hiringRoleTitle’, title);
if (country)
newFilter = newFilter.contains(‘country’, country);
$w(‘#dataset1’).setFilter(newFilter);
lastFilterTitle = title;
lastFilterCountry = country;
}
}
function loadCountries() {
wixData.query(‘Countries’)
.find()
.then(res => {
let options = [{“value”: ‘’, “label”: ‘All Countries’}];
options.push(…res.items.map(country => {
return {“value”: country.title, “label”: country.title};
}));
$w(‘#iCountry’).options = options;
});
}
However, it seems search bar doesn’t work, is there anyone can help me? Thanks.