Hi
Hope someone can help with something that I can’t manage to get working. I am trying to hide the repeater and count function until the search bar is used. I have tried a few pieces of code, but none seem to work for me. Any help with the code would be greatly appreciated.
Many Thanks
Chris
The code I have:
import wixData from ‘wix-data’;
let debounceTimer;
$w.onReady(() => {
$w("#searchBar").onKeyPress(function () {
$w("#image6").show();
$w("#searchBar").value;
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w("#searchBar").value);
}, 200);
})
//COUNT SEARCH FUNCTION
function countItems() {
let count = $w(“#dataset1”).getTotalCount()
count > 0 ? $w(“#textResults”).text = ${count} Eateries
: $w(“#textResults”).text = No Eateries Found 😥
;
return countItems;
}
//LOAD COUNT WHEN DATASET IS READY
$w(“#dataset1”).onReady(function () {
countItems();
});
// CLEAR SEARCH CODE
$w(‘#image6’).onClick(() => {
$w(“#searchBar”).value = undefined
$w(“#dataset1”).setFilter(wixData.filter()).then(countItems())
$w(“#image6”).hide();
})
})