I am having issues with a search that I have put on my dynamic (all) page. The problem is, you have to go back to the home page, and click back into the search area for it to work. How can I fix this problem and have it work immediately? The source code I wrote for this is below. Thanks!
import wixData from 'wix-data';
$w("#propertiesRepeater").hide();
export function button5_click(event) {
$w('#propertiesDataset').setFilter(wixData.filter());
$w('#searchBar').value = undefined;
$w('#button4').show();
$w('#button4').enable();
}
let debounceTimer;
export function searchBar_keyPress(event) {
if (debounceTimer){
clearTimeout (debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(()=> {($w('#searchBar').value);},200);
wixData.query('Properties').contains('city',$w('#searchBar').value)
.or(wixData.query("Properties").contains("cityOr", $w('#searchBar').value))
.find()
.then(results => {
$w('#propertiesRepeater').data = results.items;
});
}
$w('#button5').hide();
export function button4_click(event) {
search();
$w('#button4').enable();
$w("#propertiesRepeater").show();
}
export function button4_dblClick(event) {
search();
$w('#button4').enable();
$w("#propertiesRepeater").show();
}
function search() {
wixData.query("Properties")
.contains("city", $w('#searchBar').value)
.or(wixData.query("Properties").contains("cityOr", $w('#searchBar').value))
.find()
.then(results => {
$w('#propertiesRepeater').data = results.items;
});
$w('#button5').show();
$w('#button5').enable();
}
No, I am wanting to show the result from the repeater if the items are found. Like they are doing now. Other wise I just want it to say "Sorry, no results found."
Also, this code is published live. It works properly in preview, but not published mode.