I’m not having any luck getting a search to work. I’ve tried 3 different codes, with the one from this video ( https://www.youtube.com/watch?v=Hx7_8-lRsW0&feature=youtu.be ) actually doing something, but it just takes away all of my results. I do not need or want a drop down like this video has. My site is https://www.bwchurches.org/churchlist . Also, if you have any tips on getting it to load faster, they’d be appreciated with 170 churches.
Some info: database is called Churches; the search boxes across the top are 3, 1, and 2 (I just add a new box with each trial); my repeater is #repeater2; and here is my code:
import wixData from “wix-data”;
export function searchButton_click(event) {
//Runs a query on the “Churches” collection
wixData.query(“churches”)
// Query the collection for any items whose “church” field contains
// the value the user entered in the input element
.contains (“church”, $w(“#searchBox”).value)
.find() // Run the query
.then(res => {
//Set the table data to be the results of the query
$w(“#repeater2”).rows = res.items;
})
}
let debounceTimer;
export function SearchBox2_keyPress(event, $w) {
if (debounceTimer){
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#SearchBox2’).value);
}, 200);
}
let lastfiltertitle;
function filter(Church) {
$w(‘#dynamicDataset’).setFilter(wixData.filter().contains(‘church’, Church));
lastfilterTitle = Church
}
$w.onReady( function () {
$w('#SearchBox3').onClick( function () {
wixData.query("Churches")
.contains("Church", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("Denomination", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("StreetAddress", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("City", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("WorshipStyle", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("ServiceTimes", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("FirstNamePastor", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("LastNamePastor", $w("#SearchBox3").value)
.or(wixData.query("Churches")
.contains("YouthSErviceTimes", $w("#SearchBox3").value)))))))))
.find()
.then((results) => {
let resultsItems = results.items;
console.log(resultsItems);
$w('#repeater2').container = resultsItems;
})
})
})