I’m extremely new to coding on Velo, but I have tried to scrape together some code that involves a search function with repeaters. I had gotten it to work with the dropdown menu and search bar, but I’ve recently tried adding a colored background to the repeater according to a field column in the dataset. However, the search functions no longer work. Does anyone know how I could fix this?
import wixData from “wix-data” ;
$w . onReady (() => {
loadArea ();
});
let lastFilterTitle ;
let lastFilterArea ;
export function iArea_change_1 ( event ) {
filter ( lastFilterTitle , $w ( ‘#iArea’ ). value );
}
let debounceTimer ;
export function iTitle_keyPress_1 ( event ) {
if ( debounceTimer ) {
clearTimeout ( debounceTimer );
debounceTimer = undefined ;
}
debounceTimer = setTimeout (() => {
filter ( $w ( ‘#iTitle’ ). value , lastFilterArea );
}, 200 );
}
function filter ( title , area ) {
if ( lastFilterTitle !== title || lastFilterArea !== area ) {
let newFilter = wixData . filter ();
if ( title )
newFilter = newFilter . contains ( ‘title’ , title );
if ( area )
newFilter = newFilter . contains ( ‘area’ , area );
$w ( ‘#dataset1’ ). setFilter ( newFilter );
lastFilterTitle = title ;
lastFilterArea = area ;
}
}
function loadArea ( ) {
wixData . query ( ‘Area’ )
. ascending ( “area” )
. find ()
. then ( res => {
let options = [{ “value” : ‘’ , “label” : ‘All Areas’ }];
options . push (… res . items . map ( Area => {
return { “value” : Area . title , “label” : Area . title };
}));
$w ( ‘#iArea’ ). options = options ;
});
}
let it = $w ( “#dataset1” ). getCurrentItem ();
let val = it . business ;
export function repeater1_itemReady_1 ( $item , itemData , index ) {
$item ( “#box1” ). style . backgroundColor = it . business ;
}