Set up a simple search as per the example, https://www.wix.com/velo/example/search-a-database
When run the code in preview, everything works perfectly. Publish and switch to live and the dropdown box is not displaying anything.
The only error I get in the log is run/preview log is;
Wix code SDK Warning: The selectOption parameter at index 12 that is passed to the options function cannot be set to [object Object]. Options must contain either a non-null value or a non-null label. - Line 45
Copy of the code here:
import wixData from “wix-data” ;
$w . onReady (() => {
loadDepartments ();
});
let lastFilterTitle ;
let lastFilterDepartment ;
let debounceTimer ;
export function iTitle_keyPress_1 ( event , $w ) {
if ( debounceTimer ) {
clearTimeout ( debounceTimer );
debounceTimer = undefined ;
}
debounceTimer = setTimeout (() => {
filter ( $w ( ‘#iTitle’ ). value , lastFilterDepartment );
}, 500 );
}
export function iDepartment_change_1 ( event , $w ) {
filter ( lastFilterTitle , $w ( ‘#iDepartment’ ). value );
}
function filter ( title , department ) {
if ( lastFilterTitle !== title || lastFilterDepartment !== department ) {
let newFilter = wixData . filter ();
if ( title )
newFilter = newFilter . contains ( ‘title’ , title );
if ( department )
newFilter = newFilter . contains ( ‘department’ , department );
$w ( ‘#dataset1’ ). setFilter ( newFilter );
lastFilterTitle = title ;
lastFilterDepartment = department ;
}
}
function loadDepartments ( ) {
wixData . query ( ‘Departments’ )
. find ()
. then ( res => {
let options = [{ “value” : ‘’ , “label” : ‘All Departments’ }];
options . push (… res . items . map ( department => {
return { “value” : department . title , “label” : department . title };
}));
$w ( ‘#iDepartment’ ). options = options ;
});
}
This has puzzled me for 2 days now