I have a repeater on a page that is meant to show only one Item at a time. The Item is meant to change based on selection from a dropdown.
Each Item can have up to six buttons (each button pulls a link from the dataset), but most items do not all six. When the link field in the dataset is empty, the related button is mean to collapse.
I’ve written code to control the collapse or expand of the buttons, and it works in preview mode, but not live.
Here’s a sample page:
commondeerpress. com/books-1/the-girl-from-the-attic
Selecting “Paperback” in the dropdown should result in 5 buttons being shown (Amazon, Barnes&Noble, Indigo, IndieBound, and Bookshop)
Selecting “Ebook” in the dropdown should result in 4 buttons being shown (Amazon, Barnes&Noble, Indigo, and CDP Store)
Selecting “Hardcover” in the dropdown shows nothing for now (that’s an unrelated issue).
All this works at first, but if you switch the dropdown again (from Ebook to Paperback) the buttons get messed up (though the links still go to the right places).
Here’s the code I’m using for the CDP Store button (which I repeat for the other buttons):
$w.onReady(() => {
$w("#dataset3").onReady(() => {
const item = $w("#dataset3").getCurrentItem();
if (!item.cdpStore) {
$w("#button25").collapse();
}
})
$w("#dataset3").onCurrentIndexChanged(() => {
const item = $w("#dataset3").getCurrentItem();
if (!item.cdpStore) {
$w("#button25").collapse();
}
else {$w("#button25").expand();}
});
});
Again, this works fine in preview mode no matter how many times I switch between dropdown options. But it doesn’t work on live after multiple switches of the dropdown.
Can anyone help?