import wixData from ‘wix-data’ ;
$w.onReady( function () {
let tags = $w( ‘#tags’ );
if (tags.value.length === 1 ) {
prevSelectedValue = tags.value[ 0 ];
} else if (tags.value.length > 1 ) {
// If multiple tags are selected by default, deselect all of them (since there’s no good reason to prefer one of them over the others).
tags.value = ;
}
});
export function selectionTags_change(event) {
// Prevent deselecting the only selected tag. Radio buttons do not allow it so tags shouldn’t either.
if (!event.target.value || event.target.value.length === 0 ) {
// Re-apply the previously selected tag.
event.target.value = [prevSelectedValue];
// Replace the previously selected tag with the newly selected one.
} else {
// Note: Array.filter() was added in ES7. Only works in some browsers.
event.target.value = event.target.value.filter(x => x !== prevSelectedValue);
prevSelectedValue = event.target.value[ 0 ];
}
}
const collectionName = ‘nuevodataset’ ;
const fieldToFilterByInCollection = ‘tags’ ;
$w.onReady( function () {
setRepeatedItemsInRepeater();
loadDataToRepeater();
$w( ‘#tags’ ).onChange((event) => {
const selectedTags = $w( ‘#tags’ ).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;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
})
}
export function setRepeatedItemsInRepeater()
image ').src = itemData.image;
‘#title’ .text = itemData.title;
})