Thank you. I tried that and the best I can get is it deselects the first tag, but it still shows the results for 2 tags. When I click a 3rd tag, it clears the first one.
Can you tell me what I’m doing wrong?
Here’s my code currently.
// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
});
import wixData from 'wix-data';
const databaseName = 'Books';
const databaseField = 'tropes';
$w.onReady(function () {
$w('#selectionTags1').onChange((event) => {
const selectedTag = $w('#selectionTags1').value;
addItemstoRepeater(selectedTag);
})
});
function addItemstoRepeater(selectedOption = [0]) {
let dataQuery = wixData.query(databaseName);
if (selectedOption.length > 0) {
dataQuery = dataQuery.hasSome(databaseField, selectedOption);
}
dataQuery
.find()
.then(results => {
const filtereditemsReady = results.items;
$w('#repeater2').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("nothing")}
}
console.log (VALUE)
setTimeout (() => {
$w('#selectionTags1').value = []
$w('#selectionTags1').value = VALUE
},1)
})
});