Hi, I need help!
I've been working on this code for days. I've tried a million ways to show a "No Results" message if query comes back = 0. I did it in a million different ways and still the "No Results" text box doesn't show up. Can someone help verifying my code and see what am I doing wrong? Thanks!
import wixData from 'wix-data';
$w('#resetButton').hide();
$w.onReady(function () {
});
export function searchButton_click(event) {
search();
}
function search() {
wixData.query("Courses1")
.contains("order",String($w('#dropdown1').value))
.and(wixData.query("Courses1")).contains("location",String($w('#dropdown2').value))
.find()
.then(results => {
$w('#listRepeater').data = results.items;
});
$w('#resetButton').show();
$w('#resetButton').enable();
$w('#searchButton').hide();
}
export function resetButton_click(event) {
$w('#dynamicDataset').setFilter(wixData.filter());
$w('#dropdown1').value = undefined;
$w('#dropdown2').value = undefined;
$w('#searchButton').show();
$w('#searchButton').enable();
$w('#resetButton').hide();
}
export function searchbutton_click(event){
search();
}
function find() {
wixData.query("Courses1")
.contains("order",String($w("#dropdown1").value))
.and(wixData.query("Courses1")
.contains("location",String($w("#dropdown2").value)))
.find() // Run the query
.then(results => {
if (results.items.length > 0) {
$w('#listRepeater').data = results.items;
} else {
$w("#listRepeater").hide();
$w('#noresultsText').show();
console.log("No Results")
}
})
}
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
![feature fixed.png](https://static.wixstatic.com/media/3bfa8a_f845e1016b8a49758acdd6edd6610c3b~mv2.png/v1/crop/x_0,y_2,w_852,h_508/fill/w_104,h_62,al_c,q_85,usm_0.66_1.00_0.01,blur_3,enc_auto/feature%20fixed.png)
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
What is returning in your results.items? If it is never 0, see what is returning so you know what to evaluate on.