Question:
I was trying to connect a footer menu clickable textbox to a dropdown menu so it would filter my repeater accordingly, but while trying to make it work by code, the filtering failed to do so and the repeater did not show any items at all.
What are you trying to achieve:
I want to filter the items in the repeater by a dropdown menu. The tags in the dropdown menu are connected to the dataset, but I want to filter the repeater by clicking on a textbox in the footer menu. Clicking the textbox will redirect me to the specific page I want, and then show the clicked option on the dropdown menu bar and will filter the repeater accordingly.
What have you already tried:
That is my footer menu code:
import { session } from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(() => {
const footerMenuMapping = {
"#textDigitalMarketing": "Digital Marketing",
};
Object.keys(footerMenuMapping).forEach(textBoxId => {
$w(textBoxId).onClick(() => {
const selectedCategory = footerMenuMapping[textBoxId];
session.setItem("selectedCategory", selectedCategory);
wixLocation.to("/marketing-consultants");
});
});
});
That is the code on the page where I was trying to apply the filtering:
import { session } from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(() => {
const selectedCategory = session.getItem("selectedCategory");
if (selectedCategory) {
$w("#subTagsDropdown1").value = selectedCategory;
$w("#dynamicDataset").setFilter(
wixData.filter().contains("Sub Service", selectedCategory)
)
.then(() => {
console.log(`Success: ${selectedCategory}`);
})
.catch(err => {
console.error("Error:", err);
});
session.removeItem("selectedCategory");
}
});