Hello everybody! Hope you’re having a fabulous day.
I am not - because a simple code has been bugging me for a while now.
I have a repeater (#repeater4) that is filtered through multiple filtering options (dropdowns and selection tags). This works great. The problem is the following:
I want to display a message when the search shows no results. I have a text field ( #noResults).
The property value of this text field is hidden on load, since I want it to be visible only when the filtering search gives no results.
Example: you select options from my dropdown menus, click search but end up with no results, thus the “noResults” text field pops up.
I have triple checked everything, including names, code etc. I am getting no errors in the console. Problem is, the message just does not show up It stays hidden when no results are found.
I could really use assistance and kindly ask you, dear reader, to help me. I’ve read all of the similar posts on this forum and tried every code posted to no avail. So here is my code - I highlighted the lines of code relevant to this post and pasted the whole code in case I’ve misplaced certain lines of code regarding this. Please help!!! I beg of you.
Thank you so much
import wixData from ‘wix-data’ ;
import wixWindow from ‘wix-window’ ;
//start of JobField dropdown - work please i beg of
$w . onReady (() => {
errorTextResult ();
$w ( “#dataset1” ). onReady (() => {
$w ( “#repeater4” ). onItemReady (( $item , itemData , index ) => {
$item ( ‘#viewButton’ ). onClick (() => {
wixWindow . openLightbox ( ‘Cheese’ , itemData )
});
});
});
$w ( ‘#clearButton’ ). onClick (() => {
$w ( “#countryDropdown” ). value = undefined
//$w(“#companyType”).value = undefined
$w ( “#employment” ). value = undefined
$w ( “#companySize” ). value = undefined
$w ( “#checkboxGroup1” ). value = undefined
$w ( “#benefits” ). value = undefined
//$w(“#approved”).value = undefined
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. eq ( ‘field’ , location ))
});
});
export function searchButton_click ( event ) {
search ();
}
function search () {
let selectedTags = $w ( “#benefits” ). value ;
wixData . query ( “jobpostings” )
. contains ( “field” , String ( $w ( “#countryDropdown” ). value ))
// .and(wixData.query(“jobpostings”).contains(“location”, String($w(“#companyType”).value)))
. and ( wixData . query ( “jobpostings” ). contains ( “type” , String ( $w ( “#employment” ). value )))
. and ( wixData . query ( “jobpostings” ). contains ( “remote” , String ( $w ( “#checkboxGroup1” ). value )))
. and ( wixData . query ( “jobpostings” ). contains ( “companyType” , String ( $w ( “#companySize” ). value )))
. and ( wixData . query ( “jobpostings” ). hasAll ( “benefits2” , selectedTags ))
// .and(wixData.query(“jobpostings”).contains(“partners”, String($w(“#approved”).value)))
. find ()
. then ( results => {
$w ( “#repeater4” ). data = results . items ;
});
}
export function input1_keyPress ( event ) {
let SearchValue = $w ( “#input1” ). value ;
$w ( “#dataset1” ). setFilter ( wixData . filter (). contains ( ‘title’ , SearchValue )
. or ( wixData . filter (). contains ( ‘location’ , SearchValue ))
. or ( wixData . filter (). contains ( ‘field’ , SearchValue ))
. or ( wixData . filter (). contains ( ‘type’ , SearchValue ))
. or ( wixData . filter (). contains ( ‘organization’ , SearchValue )));
}
function errorTextResult () {
$w ( ‘#dataset1’ ). onReady ( () => {
let count = $w ( ‘#dataset1’ ). getTotalCount ();
**if** ( count > 0 ) {
$w ( '#noResults' ). hide ();
}
**if** ( count === 0 ) {
$w ( '#noResults' ). show ();
}
});
}