I followed the no result found code on here and added to my site. Can you tell me if I did it correctly because it’s not working. I want the user to filter by Category, City & State. if no results it should populate a message. Thanks for your help.
Below is my code:
import wixData from ‘wix-data’;
$w.onReady( function () {
//TODO: write your page related code here…
});
export function searchbutton_click(event, $w) {
$w(“#dataset2”).setFilter(wixData.filter()
.contains("category", $w('#vendordropdown').value)
.and(wixData.filter()
.contains("cityState",$w('#cityandstatedropdown').value)
)
).then((results) => {
console.log("Dataset2 is now filtered");
$w('#Vendorlist').data = results.items;
}). **catch** ((err) => {
console.log(err);
});
$w(‘#Vendorlist’).expand();
}
function search() {
wixData.query(‘category’)
.eq(‘category’,
$w(“vendordropdown”).value)
.find()
.then(res1 => {
if (res1.items.length===0){
wixData.query(‘category’)
.eq(“category’,000”)
.find()
.then(res2 => {
$w(‘#Vendorlist’).data=res2.items;
})
. catch ((error)=> {
let errormsg = error;
});
}
$w(‘#Vendorlist’).data=res1.items;
})
. catch ((error)=> {
let errorMsg = error;
});
}