Ever wonder how you can manipulate a Repeater to change the layout of specific items inside?
Check out my new tutorial on how to create a repeater with a "zebra" layout by using the multi-state box!
Credit for the idea goes to the amazing @Ido Hershkovits!
Here is the code I used (Make sure the element IDs match the IDs in your code):
$w.onReady(function () {
$w('#repeater1').forEachItem(($item, itemData, index) => {
if (index % 2 === 0) {
$item('#multiStateBox1').changeState("even");
} else {
$item('#multiStateBox1').changeState("odd");
}
})
});
**If you decide to populate the repeater using a database, then use the onItemReady() function in the code instead of the forEachItem() function.
👍🏻
Useful, helpful, interesting solution. Thanks.