Hello, I am having issues with my checkboxes not checking in my repeater, they show what was selected when you post an entry in the database and won’t let me custom check anything.
Here is my code, if you can help I would deeply appreciate it, everything I have searched online hasn’t helped… Thanks!
import { local } from ‘wix-storage’ ;
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
var sameWord = local . getItem ( “searchWord” );
$w ( “#searchBar” ). value = sameWord ;
$w ( “#searchBar” ). placeholder = sameWord ;
// $w(‘#dataset1’).onReady(function) () {
search ();
});
// });
export function searchButton_click_1 ( event ) {
search ();
}
function search ( ) {
wixData . query ( 'AdMe Database' )
. contains ( 'fullName' , $w ( "#searchBar" ). value )
. or ( wixData . query ( 'AdMe Database' ). contains ( 'ad title' , $w ( "#searchBar" ). value ))
. or ( wixData . query ( 'AdMe Database' ). contains ( 'country' , $w ( "#searchBar" ). value ))
. or ( wixData . query ( 'AdMe Database' ). contains ( 'city / state / province' , $w ( "#searchBar" ). value ))
. or ( wixData . query ( 'AdMe Database' ). contains ( 'price' , $w ( "#searchBar" ). value ))
. find ()
. then ( res => {
$w ( '#repeater1' ). data = res . items ;
});
}
const databaseName = ‘AdMe Database’ ;
const databaseField = ‘Ad Category, Sex Category, Age Category’
$w . onReady ( function () {
$w ( ‘#checkboxGroup1’ ). onChange (( event ) => {
const selectedBox = $w ( ‘#checkboxGroup1’ ). value ;
addItemstoRepeater ( selectedBox );
$w ( ‘#checkboxGroup2’ ). onChange (( event ) => {
const selectedBox = $w ( ‘#checkboxGroup2’ ). value ;
addItemstoRepeater ( selectedBox );
$w ( ‘#checkboxGroup3’ ). onChange (( event ) => {
const selectedBox = $w ( ‘#checkboxGroup3’ ). value ;
addItemstoRepeater ( selectedBox );
})
});
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 ;
}