Dear Wix community!
I have been trying to write the code the whole day but, unfortunately, it doesn’t want to work for me. Hopefully, there is someone who can help, I’d be really really happy!
I have a code for filtering the search in repeater (found it on Youtube). It works perfectly!
However, I’d need to collapse the whole repeater when no items are found.
There is the code for filtering:
import wixData from ‘wix-data’ ;
let debounceTimer ;
export function search_keyPress ( event ) { //enable onKeypress for input form
$w ( “#clearSearch” ). show ();
$w ( “#search” ). value ;
if ( debounceTimer ) {
clearTimeout ( debounceTimer );
debounceTimer = undefined ;
}
debounceTimer = setTimeout (() => {
filter ( $w ( “#search” ). value ); //ID of input form
}, 200 );
}
let searchWord ;
function filter ( search ) {
if ( searchWord !== search ) {
$w ( “#dataset1” ). setFilter ( wixData . filter (). contains ( ‘title’ , search )); // ID of the dataset
searchWord = search ;
}
}
// CLEAR SEARCH CODE
$w . onReady (() => {
$w ( '#clearSearch' ). onClick (() => {
$w ( "#search" ). value = **undefined**
$w ( "#dataset1" ). setFilter ( wixData . filter ())
$w ( "#clearSearch" ). hide ();
})
})
In case someone knows what to add to collapse the repeater when no items are found, please, let me know in the comments. I’d appreciate the whole code what and where to add as I am not really good at programming.
Thank you!!
Dominik