simple multiple search
12 items found
import wixData from 'wix-data';
$w.onReady(function () {
//SEARCH BUTTON TRIGGER⚡
$w("#searchButton").onClick(function () {
search();
});
//ENTER KEY TRIGGER⚡
$w("#searchBar").onKeyPress(function (event) {
if (event.key === "Enter") {
search();
}
});
//SEARCH FUNCTION🚀
function search() {
$w("#dataset1").onReady(function () {
$w("#dataset1").setFilter(wixData.filter().contains('cuisine', String($w('#dropdown1').value))
.and(wixData.filter().contains("location", String($w('#location').value)))
.and(wixData.filter().contains("title", String($w('#searchBar').value))))
.then(count)
$w("#clearFilter").show();
})
}
//COUNT FUNCTION👍
function count() {
let count = $w("#dataset1").getTotalCount();
if (count > 0) {
$w("#countText").text = `${count} items found`;
} else { $w("#countText").text = `No item found`; }
return count;
}
//SCROLL TO THE TOP WHEN PAGINATION IS CHANGED ⚡
$w("#pagination1").onClick(() => {
$w("#anchor1").scrollTo();
});
//CLEAR FILTER 🚀
$w("#clearFilter").onClick(function () {
$w("#dropdown1").value = undefined;
$w("#searchBar").value = undefined;
$w('#location').value = undefined;
$w("#clearFilter").hide();
$w("#dataset1").setFilter(wixData.filter()).then(count);
});
//COUNT BEFORE PAGE LOADS❗
$w("#dataset1").onReady(function () {
count();
});
});