Filter Working Differently In Preview vs Live

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("#dataset3").onCurrentIndexChanged(() => {
        const item = $w("#dataset3").getCurrentItem();
        if (!item.cdpStore) {
       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?

Try to see if putting the .onCurrentIndexChanged inside the $w(“#dataset3”).onReady helps (not sure).

Anyway I think it’ll be easier to filter via code (and not with the UI editor).
and once the filtering gets fulfilled => get the current item and run the collapse expand.

Putting the .onCurrentIndexChanged inside the $w(#dataset3).onReady doesn’t seem to make any difference. Same issue occurs.

@emily40267 try filtering by code.

@jonatandor35 Any resources for filtering by code you can point me to?