Buttons in Wix repeater not updating correctly—some disappear after filtering, while all buttons incorrectly appear on page load instead of following visibility rules.
Question/Overview:
I am experiencing issues with button visibility in my Wix repeater on my Testimonials page.
When filtering content using a dropdown menu, the “SEE GALLERY” and “SEE PRODUCT” buttons disappear and do not reappear when the filter is removed, even when they should be visible. Additionally, when the page initially loads, all three buttons (including “NOT AVAILABLE”) are incorrectly visible by default, even though the custom code should be controlling their visibility based on the data conditions.
Product:
Wix Editor with Velo (Custom Code) – Dynamic Pages and Repeaters.
What I am trying to achieve:
I have a dynamic testimonials page where each repeater card has three overlapping buttons. These buttons should not all be visible on load; instead, their visibility should be determined dynamically based on data from my CMS and the dropdown menu (#dropdown1
).
- “SEE GALLERY” button (
#button107
) should be visible if aportfolioReference
field has a value. - “SEE PRODUCT” button (
#button109
) should be visible if aproductReference
field has a value. - “NOT AVAILABLE” button (
#button110
) should only be visible if neither of the above fields has a value.
What is going wrong:
However, when any filtering is applied via #dropdown1
, the “SEE GALLERY” and “SEE PRODUCT” buttons disappear on all cards, even if their conditions are met, leaving a blank space where they should be visible. Meanwhile, the “NOT AVAILABLE” button continues to work correctly. Additionally, once the “SEE GALLERY” and “SEE PRODUCT” buttons disappear after filtering, they don’t return when the filter is cleared.
What I have already tried:
- Implemented dataset filtering with code rather than relying on Wix’s dataset settings, as suggested by another developer (@dan). This is successfully filtering the repeater content but has not resolved the button issue.
- Applied
onReady
to the dataset after filtering to ensure the button logic runs only after the dataset is fully loaded. However, this did not fix the issue. - Ensured all buttons are hidden by default before applying visibility logic to prevent them from stacking. Despite this, all buttons remain visible on page load.
- Used
console.log
debugging to confirm thatapplyButtonLogic()
runs after filtering, but the buttons still do not update correctly.
Additional information:
Here is the entire custom code for the page:
import wixData from 'wix-data';
$w.onReady(() => {
$w('#dropdown1').onChange(() => {
const selectedValue = $w('#dropdown1').value;
if (!selectedValue || selectedValue === "All") {
$w('#dynamicDataset').setFilter(wixData.filter())
.then(() => {
$w("#dynamicDataset").onReady(() => {
applyButtonLogic();
});
})
.catch((err) => {
console.error("Error clearing filter:", err);
});
} else {
$w('#dynamicDataset').setFilter(wixData.filter().eq("typeOfFeedback", selectedValue))
.then(() => {
$w("#dynamicDataset").onReady(() => {
applyButtonLogic();
});
})
.catch((err) => {
console.error("Dataset filter error:", err);
});
}
});
});
function applyButtonLogic() {
$w("#repeater4").onItemReady(($item, itemData) => {
$item("#button107").hide();
$item("#button109").hide();
$item("#button110").hide();
const portfolioReference = itemData["portfolioReference"];
if (portfolioReference && portfolioReference.length > 0) {
$item("#button107").show();
}
const productReference = itemData["productReference"];
if (productReference && productReference.length > 0) {
$item("#button109").show();
}
if ((!portfolioReference || portfolioReference.length === 0) && (!productReference || productReference.length === 0)) {
$item("#button110").show();
}
});
}
Any help in understanding
- why all three buttons are visible on page load, and
- why the “SEE GALLERY” and “SEE PRODUCT” buttons are disappearing after filtering and not reappearing when the filter is cleared would be greatly appreciated! Let me know if additional context is needed.