I have written my code to query a search based on a name, and then to further narrow the search I created a drop down for “state”. I want to create a second dropdown for “city” and then a checkbox filter to narrow the search even further (using tags from a db). Here is my code. Can someone help me figure out how to do this?
import wixData from "wix-data";
$w.onReady(() => {
wixData.query('States')
.find()
.then(res => {
let options = [{"value": '', 'label': 'All States'}];
options.push(...res.items.map(state => {
return {'value': state.title, 'label': state.title}
}));
$w('#iState').options = options;
})
});
let lastFilterTitle;
let lastFilterState;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#iTitle').value, lastFilterState);
}, 200);
}
function filter(title, state) {
if (lastFilterTitle !== title || lastFilterState !== state) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('breweryName', title);
if (state)
newFilter = newFilter.eq('state', state);
$w('#dataset4').setFilter(newFilter);
lastFilterTitle = title;
lastFilterState = state;
}
}
export function iState_change(event, $w) {
filter(lastFilterTitle, $w('#iState').value);
}
I appreciate the links but it looks like a lot of these are dealing with tables. I am using a repeater to search on results. There have been other posts with people helping solve the specific code they’re trying to deploy and that is what I’m looking for. If there are variables I’m missing and can get help filling those in, that would be greatly appreciated.