HI @evesilberx thanks for teh super simple explanation. Do you know, if this works also with more than two variations? I’m trying to build one with three different states but am struggling with the state changes to be applied.
Do you maybe have an idea?
Thanks in advance
Oh I just figured it out! Guess it will work also with more items exactly like that.
$w.onReady(function () {
$w('#VCPortfolioRepeater').forEachItem(($item, itemData, index) => {
const multiStateBox = $item('#PortfolioItemBox');
// Determine the state based on the item's index
const layoutIndex = index % 3;
let stateName;
switch (layoutIndex) {
case 0:
stateName = "Middle";
break;
case 1:
stateName = "Bottom";
break;
case 2:
stateName = "Top";
break;
default:
console.error(`Unexpected layout index: ${layoutIndex}`);
return;
}
// Change to the appropriate state
multiStateBox.changeState(stateName)
.then(() => console.log(`Item ${index} set to state: ${stateName}`))
.catch(err => console.error(`Error changing state for item ${index}:`, err));
});
});