I changed a little bit your code, since still some code-lines very strange!
Try this one…
Also found some more copy&paste-bugs made by my own…
Please check first the whole code, for any bugs or missing or wrong IDs or values.
import { local } from 'wix-storage';
import wixData from 'wix-data';
///------------------------
let DATABASE = 'AdMe Database';
let dbField = [];
dbField[0] = 'Ad Category';
dbField[1] = 'Sex Category';
dbField[2] = 'Age Category';
let mySelectedOptions = [];
$w.onReady(()=> {console.log("Page is ready...");
// FIRST GETTING SOME DATA OUT OF Wix-Storage......
var searchValue = local.getItem("searchWord");
// filling your searchbar with the memorized value....
if(typeof searchValue === 'string') {
$w("#searchBar").value = searchValue;
$w("#searchBar").placeholder = searchValue;
}
$w('#searchButton').onClick(async(event)=> {console.log(event.target.id+"-clicked!");
// starting the SEARCH-FUNCTION...after a click onto the SEARCH-BUTTON....
let resData = await search(searchValue);
console.log("My RESULTS = ", resData);
});
$w('#checkboxGroup1').onChange((event)=> {console.log(event.target.id+"-clicked!");
let selectedCBG = (event.target.id).substring(event.target.id.length - 1); console.log(selectedCBG);
const mySelectedOptions = $w('#checkboxGroup1').value;
addItemstoRepeater(mySelectedOptions);
console.log(" mySelectedOptions ", mySelectedOptions);
});
$w('#checkboxGroup2').onChange((event)=> {console.log(event.target.id+"-clicked!");
let selectedCBG = (event.target.id).substring(event.target.id.length - 1); console.log(selectedCBG);
const mySelectedOptions = $w('#checkboxGroup2').value;
console.log(" mySelectedOptions ", mySelectedOptions);
addItemstoRepeater(mySelectedOptions);
});
$w('#checkboxGroup3').onChange((event)=> {console.log(event.target.id+"-clicked!");
let selectedCBG = (event.target.id).substring(event.target.id.length - 1); console.log(selectedCBG);
const mySelectedOptions = $w('#checkboxGroup3').value;
console.log(" mySelectedOptions ", mySelectedOptions);
addItemstoRepeater(mySelectedOptions);
});
});
// --------------- MY-FUNCTIONS -----------------------------------
function search(searchValue) {
wixData.query(DATABASE).contains('fullName', searchValue)
.or(wixData.query(DATABASE).contains('ad title', searchValue))
.or(wixData.query(DATABASE).contains('country', searchValue))
.or(wixData.query(DATABASE).contains('city / state / province', searchValue))
.or(wixData.query(DATABASE).contains('price', searchValue))
.find()
.then((res)=> {console.log("FOUND-DATA after SEARCH-PROCESS: ", res);
$w('#repeater1').data = res.items;
return (res);
}).catch((err)=>{console.log("ERROR: ", err);});
}
function addItemstoRepeater(mySelectedOptions, selectedCBG) {
let dataQuery = wixData.query(DATABASE);
if (mySelectedOptions.length>0) {
dataQuery = dataQuery.hasSome(dbField[selectedCBG], mySelectedOptions);
dataQuery.find().then((results)=> {console.log("ITEMS: ", results.items);
const filtereditemsReady = results.items;
$w('#repeater1').data = filtereditemsReady;
});
}
else {console.log("No selected options found!!!");}
}
Run your FILTER while monitoring the logs in console.
Something changed?