Hi,
I am having problems with my page. I tried so many times to amend this but unable to solve this. My aim is for clients to search for food items but the page takes a long time to load. I have minimised the page to a repeater, some text, input text, header and no photos. was wondering whether it is the code issue. Please help thanks. The code is as follows:
import wixData from ‘wix-data’;
let listSize;
let currIndex = -1;
let debounceTimer;
$w.onReady(function () {
$w(‘#SearchInput’).onKeyPress((event) => {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
if ($w(‘#SearchInput’).value.length === 0) {
currIndex = -1;
$w(“#repeaterDropdown”).collapse()
.then(() => {
console.log(“Done with collapse”);
});
currIndex = -1;
}
});
wixData.query("FoodCompositionTable")
.contains("foodItemName", $w('#SearchInput').value)
.limit(10)
.find()
.then((res) => {
$w('#repeaterDropdown').data = [];
$w('#repeaterDropdown').data = res.items;
listSize = res.items.length;
$w('#repeaterDropdown').expand();
}, 10)
}
);
});
export function repeaterDropdown_itemReady($item, itemData, index) {
$item(‘#ItemName’).text = itemData.foodItemName;
$item(‘#container2’).onClick(() => {
$w(‘#SearchInput’).value = itemData.foodItemName;
$w(‘#repeaterDropdown’).collapse();
});
}
Would appreciate if you could look through the code and check whether there is a problem with it.
Thanks