You have a bad coding-style !!!
Change it !!! —> And you will have less problems !!!
import wixData from 'wix-data';
const collectionName2 = 'MyAll2';
$w.onReady(async()=> {
//Step-1:getting filter-data....
let filteredData = await filterAction();
//Step-2: ---> feeding repeater ...
$w('#productList1').data = filteredData;
//Step-3: reacting when repeater got its data...
$w('#productList1').onItemReady(async ($item, itemData) => {
if (itemData.product.discountedPrice == itemData.product.price) {
$item('#discountBox2').hide();
$item('#discount2').hide();
} else {
$item('#discount2').text = String(100 - Math.round(100 * itemData.product.discountedPrice / itemData.product.price)) + "% off";
}
const actualProduct = await wixData.query(collectionName2)
.include('brand')
.eq('product', itemData.product._id)
.find()
.then((res) => {
let items = res.items;
if (items.length > 0)
return items[0];
else
return null;
});
if (actualProduct && actualProduct.brand) {
if (actualProduct.brand.logoblack.startsWith('http://') || actualProduct.brand.logoblack.startsWith('https://') || actualProduct.brand.logoblack.startsWith('wix:image://')) {
$item('#logo1').src = actualProduct.brand.logoblack;
}
} else {
console.error("Error: Cannot read 'logoblack' property from undefined or null object.");
}
$item('#colors1').text = itemData.color.length + " colors";
if (itemData.ecoFriendly == true)
$item('#ecoFriendlySign3').expand();
if (itemData.sustainable == true)
$item('#sustainableSign3').expand();
});
//What the hell is productList? Box? Dropdown, apple, banana, a car?
//DEFINE your element-IDs the right way!!!
// It is a REPEATER --> then also declare it as a REPEATER inside of your code!!!!
// ---> repProductList <--- GOOOOOOOOOOOD !!!!!
// and again APPLE & BANANAS ????? You know what i mean!!!
//$w('#gender').onChange(async () => {
$w('#gender').onChange(async () => {
if ($w('#genderDecorBackButton').checked == true)
$w('#genderDecorBackButton').checked = false;
else
$w('#genderDecorBackButton').checked = true;
await buildFiltersAndPopulateRepeater()
});
});
async function filterAction() {
let dataQuery = wixData.query(collectionName2);
if ($w('#gender').checked == true) {
dataQuery = dataQuery.hasSome('gender', 'Women');
} else {
dataQuery = dataQuery.hasSome('gender', 'Men');
}
}