Connecting repeater and selection tags to Events App dataset

Question:
How can I filter Events according to categories using selection tags (while showcasing results in a repeater connected to Events Dataset)?

Product:
Wix Studio Editor, Events

What are you trying to achieve:
I have a repeater and selection tags connected to Events Dataset, trying to allow users to filter the repeater according to Events Category.

What have you already tried:
I have tried many things - this is the code I am currently using, the Error that come back is that the collection doesnt exist on the page, which isnt true.

import wixData from ‘wix-data’;

$w.onReady(function () {
// Add an event handler for when the selection tag value changes
$w(“#selectionTags1”).onChange((event) => {
// Get the new value of the selection tag
const newValue = event.target.value;

    // Filter the dataset based on the selected value
    filterDataset(newValue);
});

});

// Function to filter the dataset based on the selected value
function filterDataset(selectedValue) {
// Filter the dataset based on the selected value
wixData.query(“events”)
.eq(“categories”, selectedValue) // Replace “columnName” with the name of your dataset column
.find()
.then((results) => {
// Set the filtered results to the dataset
$w(“#events”).setFilter(wixData.filter().eq(“categories”, selectedValue));
// Replace “columnName” with the name of your dataset column
})
.catch((error) => {
console.error(error);
});
}

First of all…

  1. Mixing wix-predefined-stuff like dataset, with code → is a bad idea, at least if you are not very familiar with wix-coding. As you already can feel it on your own, going this way, is not very comfortable. Hundreds/1000 of people tried this in the past and had the same problems like you.

  2. Second…
    When i hear → DATASET <— the first thing what comes into my mind —>

$w.onReady(()=>{
    $w('#dataset').onReady(()=> {

    });
});

I can not find that part inside your code…
$w(‘#dataset’).onReady(()=> { }); <— you are not waiting till your DATASET gets ready.