Hello !
I used a repeater to display some projects, and added selection tags to filter the repeater content with options to be selected by site visitors. My problem is that I want that when the visitor click on one option (tag), this option is the only one selected. Its there a tip to reset the others after click on one option ?
Regards
1 Like
https://www.wix.com/corvid/example/filter-with-multiple-options
To have only one selected at a time, you would have to change the code in the example here so that only one is allowed to be selected at a time and not multiple.
Thank you for your answer!
Yes I try to do this but I don’t know what I have to change…
Is it the line with dataQuery ?
Thank a lot for your help
Here my code :
import wixData from ‘wix-data’;
const collectionName = ‘projet’;
const fieldToFilterByInCollection = ‘tags’;
$w.onReady( function () {
setRepeatedItemsInRepeater()
loadDataToRepeater()
$w(‘#tags’).onChange((event) => {
const selectedTags = $w(‘#tags’).value
loadDataToRepeater(selectedTags)
})
});
function loadDataToRepeater(selectedCategorie = []) {
let dataQuery = wixData.query(collectionName)
if (selectedCategorie.length > 0) {
dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategorie)
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items
$w(‘#projet’).data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
}
)
}
function setRepeatedItemsInRepeater() {
$w(‘#projet’).onItemReady(($item, itemData) => {
$item(‘#image5’).src = itemData.image;
$item(‘#site’).text = itemData.title;
})
}
you just have to change hasAll for hasSome.
i had the same problem…
This example does not select one tag without unclicking
hasSome shows multiple selected tags not one selected tag without unclicking.
Has anyone found out how to do this yet? I think it’s something to do with using the onChange event