Hello everybody,
I kindly ask you for a hand with some code because I can’t find the solution.
By entering one or more words (maximum 3) in a field, activating the search button should
a) create an array with the single words
b) carry out queries to search for the membership of one or all of the words in the various fields.
I’ve tried various solutions but can’t figure out where the error is. Especially hasSome doesn’t seem to work
Idea 1
export function btnSearch_click ( event ) { //butto to find)
let contentFilter = wixData . filter (); // query to variable
let wordSearch = $w ( “#fldSearch” ). value ; // list of words in a field
let listWords = wordSearch . split ( ’ ’ ). map ( w => w . trim ()). filter ( w => w ) // create array with single words (without different from uppercase and lowercase)
listWords . forEach (( words ) => {
contentFilter = contentFilter . eq ( “onSale” , true ). contains ( “hastag” , w ords ) // query to filter)
$w ( “#ddts1” ). setFilter ( contentFilter ) // filter words
})
}
Idea 2
export function btnSearch_click ( event ) { //butto to find)
let contentFilter = wixData . filter (); // query to variable
let wordSearch = $w ( “#fldSearch” ). value ; // list of words in a field
let listWords = wordSearch . split ( ’ ’ ). map ( w => w . trim ()). filter ( w => w ) // create array with single words
contentFilter = contentFilter . eq ( “onSale” , true ). hasSome ( “hastag” , w ords ) // query to filter)
$w ( “#ddts1” ). setFilter ( contentFilter ) // filter words
}
Where is the error ?
Thanks for any help!