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” )
}
})
}