I just tried to add the code in my site, it works but the selection remembers the previous tag selection. I saw the reply that you have to use the cose, but how? Thank you for your help!
The code is now the following:
import wixData from ‘wix-data’ ;
const databaseName = ‘Portainnesti’ ;
const databaseField = ‘tipo’ ;
$w . onReady ( function () {
$w ( '#selectionTags1' ). onChange (( event ) => {
**const** selectedTag = $w ( '#selectionTags1' ). value ;
addItemstoRepeater ( selectedTag );
})
});
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 ;
})
}
$w . onReady ( function () {
$w ( '#selectionTags1' ). onChange (()=>{
let VALUE = $w ( ‘#selectionTags1’ ). value
let LENGTH = VALUE . length
console . log ( LENGTH )
for ( var i = 0 ; i < LENGTH - 1 ; i ++) {
if ( LENGTH > 1 ) {
VALUE . shift ()
}
else { }
}
console . log ( VALUE )
setTimeout (()=>{
$w ( '#selectionTags1' ). value = []
$w ( '#selectionTags1' ). value = VALUE
}, 1 )
})
});