I’m having trouble with
I am trying to create a custom accordion/FAQs slice using a repeater so that I can connect the questions and answers to the CMS. I have tried using some velo code to make the answer container collapsible which works but there is still a large gap between the items in the repeater when the container is collapsed. I would like the next item to move up when the answer container is collapsed.
Working in
Wix Studio, CMS
Site link
Here is the site link https://digitalmadriver.wixstudio.com/my-site-5/exhibitions/the-last-degree-south-pole-ski?rc=test-site
What I’m trying to do
Have a fully functioning accordion style slice that can be fully editable in the CMS.
What I’ve tried so far
This is the code that I’m currently using to get the container to collapse. If anyone could take a look and tell me if there’s something wrong that would be great.
$w.onReady(function () {
$w('#itineraryrepeater').onItemReady(($item, itemData, index) => {
// Store original height
const answer = $item('#answer');
let originalHeight = null;
let isExpanded = false;
// Start collapsed
answer.collapse();
$item('#question').onClick(() => {
if (!isExpanded) {
// Expand
answer.expand();
isExpanded = true;
} else {
// Collapse
answer.collapse();
isExpanded = false;
}
// Multiple refresh attempts
$w('#itineraryrepeater').refresh();
setTimeout(() => $w('#itineraryrepeater').refresh(), 50);
setTimeout(() => $w('#itineraryrepeater').refresh(), 150);
});
});
});
Extra context
Please see screenshots of what it currently looks like open and closed. The issue is the space when the item is closed.



