So I followed a wix tutorial and I was able to get the search working fine, but my dropdown filter wasn’t working. There were no options in the drop down menu to choose from. I think there is something wrong in the $w.onReady function.
I am getting a “Wix code SDK Warning: The selectOption parameter at index 1 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.” warning for line 15 like 50 times. Line 15 is " $w( ‘#dropdown1’ ).options = options;"
Please Help!
import wixData from 'wix-data';
let fullText; // variable to hold the full text
let shortText; // variable to hold the short version of the text
$w.onReady(function () {
// $w("#dropdown1").hide();
wixData.query('CollegeMedia')
.find()
.then(res => {
let options = [{"value" : '', 'label' : 'All States'}];
options.push(...res.items.map(state =>{
return {'value': state.title, 'label': state.title};
}));
$w('#dropdown1').options = options;
})
});
let lastFilterTitle;
let lastFilterState;
let debounceTimer;
export function input5_keyPress(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#input5').value, lastFilterState);
}, 50);
}
function filter(title, state){
if (lastFilterTitle !== title || lastFilterState !== state){
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('college', title);
if (state)
newFilter = newFilter.eq('state', state);
$w('#dataset1').setFilter(newFilter);
lastFilterTitle = title;
lastFilterState = state;
}
}
export function dropdown1_change(event) {
filter(lastFilterTitle, $w('#dropdown1').value);
}