Hello, have please some idea how to put together function addItemstoRepeater and addItemstoRepeater2 put ? this code works but its not what i want. Problem is tags and dropdown not connected when i select something from tags the item in repeater is for all item from dropdown and similar when i choose some from dropdown is for all in tags. Thanks. i need some help how to put
selectedTags and selectedKraj in one function addItemstoRepeater. thanks.
import wixData from 'wix-data';
const databaseName = 'Sluzby';
const databaseFieldTags = 'sluzby';
const databaseFieldKraj = 'kraj';
$w.onReady(function () {
$w("#selectionTags1").onChange( (event) => {
const selectedTags = $w("#selectionTags1").value;
addItemstoRepeater(selectedTags)
});
$w("#dropdown6").onChange( (event) => {
const selectedKraj = event.target.value;
addItemstoRepeater2(selectedKraj)
});
});
function addItemstoRepeater(selectedOption = [] ) {
let dataQuery = wixData.query(databaseName);
if (selectedOption.length > 0 ) {
dataQuery = dataQuery.hasAll(databaseFieldTags, selectedOption);
}
dataQuery
.find()
.then(results => {
const filtereditemsReady = results.items;
$w('#repeater1').data = filtereditemsReady;
const isRepeaterEmpty = filtereditemsReady.length === 0
if (isRepeaterEmpty) {
$w('#noResultsFound').show();
} else {
$w('#noResultsFound').hide();
}
})
}
function addItemstoRepeater2(selectedOption = [] ) {
let dataQuery = wixData.query(databaseName);
if (selectedOption.length > 0 ) {
dataQuery = dataQuery.hasAll(databaseFieldKraj, selectedOption);
}
dataQuery
.find()
.then(results => {
const filtereditemsReady = results.items;
$w('#repeater1').data = filtereditemsReady;
const isRepeaterEmpty = filtereditemsReady.length === 0
if (isRepeaterEmpty) {
$w('#noResultsFound').show();
} else {
$w('#noResultsFound').hide();
}
})
}