Sure,
I use the example code I found here on the website to connect the Selectiontags to the repeater (thou I think I have pieces in the code which I don’t need). So with this code, several selectionTags elements can be in “selected” mode at the same time, and it filters repeater with “and” condition; Meaning: I have “fashion” and “cooking” tags. When both selected repeater shows no items at all. I’m trying to get to a point when I repeater would show me items which have “fashion” or “cooking” tags in the corresponding column.
I do part of the work in the interface, other part in DevMode, and don’t clearly understand what overrides?
import wixData from ‘wix-data’ ;
const collectionName = ‘masters’ ;
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( ‘#repeater2’ ).data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
})
}
<<For example, I don’t understand what does these lines mean inside of the function, Not sure if I need them at all.>>
function setRepeatedItemsInRepeater() {
$w( '#repeater2' ).onItemReady(($item, itemData) => {
$item( '#recipeImage' ).src = itemData.image;
$item( '#recipeImage' ).tooltip = itemData.recipeName;
$item( '#recipeName' ).text = itemData.recipeName
$item( '#chefName' ).text = 'By ' + itemData.chefName;
})
}