Hello, I use a dropdown to filter a repeater.
The repeater is hidden when the page is loaded and the user must select the dropdown first to get the result through the repeater.
I don’t manage to filter the repeater properly.
I’d tried for 1 week unsuccessfully, please help!!!
I use 2 database: 1 for the repeater and 1 for the dropdown
Here the codes:
import wixData from ‘wix-data’;
$w.onReady( function () {});
let selectedType = “”
export function dropdown2_change(event) {
if ($w(‘#dropdown2’).value)
$w(‘#repeater1’).show();
else {
$w(‘#repeater1’).hide();
}
wixData.query(“MyDropdownCollection”)
.eq(“title”, $w(‘#dropdown2’).value)
.find()
.then((results) => {
let firstItem = results.items[0]
selectedType = firstItem._id;
wixData.query(“MyRepeaterCollection”)
.eq(“title”, selectedType)
.find()
.then((results) => {
$w(‘#repeater1’).data = results = results.items;
})
. catch ( (err) => {
let errormsg = err;
} );
});
}
Thanks!
Mikael