import wixWindow from 'wix-window';
import wixData from 'wix-data';
$w.onReady(function () {
let language = wixWindow.multilingual.currentLanguage;
setFilterBasedOnLanguage(language);
// Add onChange event handler for the dropdown
$w("#dropdown1").onChange(() => {
let selectedValue = $w("#dropdown1").value;
applyDropdownFilter(selectedValue);
});
});
function setFilterBasedOnLanguage(language) {
if (language === "en") {
$w("#dynamicDataset").setFilter(wixData.filter().eq("language", "EN"));
} else if (language === "zh") {
$w("#dynamicDataset").setFilter(wixData.filter().eq("language", "CH"));
}
}
function applyDropdownFilter(value) {
let targetDataset = $w("#dynamicDataset"); // Replace with the ID of the dataset you want to filter
if (value) {
targetDataset.setFilter(wixData.filter().eq("category", value));
} else {
targetDataset.setFilter(wixData.filter());
}
}
export function newsRepeater_itemReady($w, itemData, index) {
let language = wixWindow.multilingual.currentLanguage;
setFilterBasedOnLanguage(language);
}
Hi, Friends! I got this problem and do not know how to solve. Hopefully anyone can help me, I really appreciate it.
the code above is used for displaying two languages on a dynamic page. It works, but if I add a drop down filter and connect it to my database, it shows all the categories in both language , and if I select any of the category and then select all, nothing will show up.
I have tried everything to make this work, but I failed.