Seems like you have some issues inside your code!
- You are using more then one → onReady-command! → NOT GOOD !
- Your onClick-Functions are not closed…
$w.onReady(function(){
$w('#checkboxGroup1').onChange((event) => {
const selectedBox = $w('#checkboxGroup1').value;
addItemstoRepeater(selectedBox);
<--- NOT CLOSED --> NOT OK!
$w('#checkboxGroup2').onChange((event) => {
const selectedBox = $w('#checkboxGroup2').value;
addItemstoRepeater(selectedBox);
<--- NOT CLOSED --> NOT OK!
$w('#checkboxGroup3').onChange((event) => {
const selectedBox = $w('#checkboxGroup3').value;
addItemstoRepeater(selectedBox);
}); // <---- CLOSED and OK !!!!
});
And this one also never will work…
function addItemstoRepeater(selectedOption = []) {
let dataQuery = wixData.query(databaseName);
if (selectedOption.length > 0) {
dataQuery = dataQuery.hasSome(databaseField,
selectedOption);
}
dataQuery
.find()
.then(results => {
const filtereditemsReady = results.items;
$w('#repeater1').data = filtereditemsReady;
}
What’s that here … ?
function addItemstoRepeater(selectedOption = []) {..........
Why you are inputing an EMPTY ARRAY into a fucntion and expecting some results?
Also using such ID’S for your → DATABASE-FIELDS ← is not one of the best ideas ! …
const dbField = 'Ad Category, Sex Category, Age Category'
Was this DB-Field created by a stupid additional APP?
Ok, let’s recode all your code from scratch!
import { local } from 'wix-storage';
import wixData from 'wix-data';
///------------------------
const DATABASE = 'AdMe Database';
const dbField = 'Ad Category, Sex Category, Age Category'
let mySelectedOptions = [];
$w.onReady(()=> {
// FIRST GETTING SOME DATA OUT OF Wix-Storage......
var searchValue = local.getItem("searchWord");
// filling your searchbar with the memorized value....
$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!");
const mySelectedOptions = $w('#checkboxGroup1').value;
addItemstoRepeater(selectedBox); console.log(" mySelectedOptions ", mySelectedOptions);
});
$w('#checkboxGroup2').onChange((event)=> {console.log(event.target.id+"-clicked!");
const mySelectedOptions = $w('#checkboxGroup2').value; console.log(" mySelectedOptions ", mySelectedOptions);
addItemstoRepeater(selectedBox);
});
$w('#checkboxGroup3').onChange((event)=> {console.log(event.target.id+"-clicked!");
const mySelectedOptions = $w('#checkboxGroup3').value; console.log(" mySelectedOptions ", mySelectedOptions);
addItemstoRepeater(selectedBox);
});
});
// --------------- MY-FUNCTIONS -----------------------------------
function search() {
wixData.query(DATABASE).contains('fullName', myValue)
.or(wixData.query(DATABASE).contains('ad title', myValue))
.or(wixData.query(DATABASE).contains('country', myValue))
.or(wixData.query(DATABASE).contains('city / state / province', myValue))
.or(wixData.query(DATABASE).contains('price', myValue))
.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) {
let dataQuery = wixData.query(databaseName);
if (mySelectedOptions.length>0) {dataQuery = dataQuery.hasSome(databaseField, selectedOption);}
dataQuery.find()
.then((results)=> {
const filtereditemsReady = results.items;
$w('#repeater1').data = filtereditemsReady;
});
}
This is not the end-solution → work on it, try to understand your own code!
DO NOT FORGET TO USE THE —> CONSOLE !!! IT WILL HELP YOU TO UNDERSTAND YOUR OWN CODE!!!