Hello! I have multiple projects in a dataset, and I have a selection tag to filter the projects. The issue is you can only select one tag at a time. If I select more than one tag, it causes issues.
Is there a way to have projects from 2 tags show up if both tags are clicked on?
Here is the code I am using:
import wixData from 'wix-data';
const collectionName = 'Projects';
const fieldToFilterByInCollection = 'tags';
$w.onReady(function () {
setRepeatedItemsInRepeater();
loadDataToRepeater();
$w('#selectionTags1').onChange((event) => {
const selectedTags = $w('#selectionTags1').value;
loadDataToRepeater(selectedTags);
})
});
function loadDataToRepeater(selectedCategories = []) {
let dataQuery = wixData.query(collectionName);
if (selectedCategories.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategories);
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items;
$w('#repeater1').data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w('#repeater1').show();
} else {
$w('#repeater1').show();
}
})
}
function setRepeatedItemsInRepeater() {
$w('#repeater1').onItemReady(($item, itemData) => {
$item('#container1').src = itemData.projectimage;
$item('#container1').tooltip = itemData.projectimage;
$item('#text68').text = itemData.projectname;
$item('#button1').text = 'By ' + itemData.projectname;
})
}