I’m trying to filter a dataset so that it only contains non-customer and filters the txtAddresses field of the collection the dataset is attached to with user input in a search bar.
When run in preview mode all of the console logs are outputted but none of the items in the collection are visible, and when I backspace, so that nothing is left in the search bar, it doesn’t go back to having all of the items visible.
I’m not sure what I’ve done wrong but any help would be greatly appreciated.
This is the code on the page:
let lastFilterTitle;
let lastFilterContinent;
let debounceTimer = true;
let newFilter = wixData.filter();
function filter(title) {
console.log("4. Filter");
if (lastFilterTitle !== title) {
console.log("5. filter");
if (title !== null) {
console.log("6. filter");
newFilter = newFilter.eq('addCustomer', false).contains('txtAddresses', title);
}
$w('#dataset1').setFilter(newFilter)
lastFilterTitle = title;
console.log("7. Filter");
}
}
export function inpSearchAddress_keyPress_1(event) {
//Add your code for this event here:
console.log("1. keypress function");
if (debounceTimer) {
console.log("2. timer if statement");
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
console.log("3. delay");
console.log($w('#inpSearchAddress').value);
filter($w('#inpSearchAddress').value);
}, 500);
}