@yisrael-wix I know that…
I’m using forEachItem() . That’s where it goes wrong. The correct data is visible in the shadow DOM (or how do you guys call it?), but it’s not being rendered to the screen.
See below another snippet to switch positions of colors within a repeater.
For the record, I’m talking about adjustments to $item(), not itemData .
$w("#button156").onClick((event) => { //switch position of colors in repeater
//insert items
var nbItems = $w("#repeater1").data.length;
var prevIndex = nbItems - 1;
var bgColor_I;
var bgColor_N;
var item
$w("#repeater1").forEachItem(($item, itemData, index) => {
console.log(index);
//item in index 0 moves to index 1 OR item in index N moves to index 0
console.log(itemData._id);
if (index === 0) {
item = "item-" + prevIndex;
console.log("item:", item);
//save item
bgColor_I = $item("#box217").style.backgroundColor;
//get item
$w("#repeater1").forItems([item], ($item, itemData, index) => {
if ($item("#box217").style.backgroundColor !== undefined) {
bgColor_N = $item("#box217").style.backgroundColor;
console.log(bgColor_N)
} else {
bgColor_N = "rgba(255,255,255,1.0)"
}
});
item = "item-" + index;
console.log("item:", item);
//store item at index
$w("#repeater1").forItems([item], ($item, itemData, index) => {
console.log(itemData._id);
console.log($item("#box217"));
console.log("new_value:")
console.log(bgColor_N)
console.log("before:")
console.log($item("#box217").style.backgroundColor);
$item("#box217").style.backgroundColor = bgColor_N;
console.log("after:")
console.log($item("#box217").style.backgroundColor);
});
} else {
item = "item-" + index;
console.log("item:", item);
//save item
$w("#repeater1").forItems([item], ($item, itemData, index) => {
bgColor_N = $item("#box217").style.backgroundColor;
});
//store item at index
$item("#box217").style.backgroundColor = bgColor_I
bgColor_I = bgColor_N;
}
});
});
Site URL:
https://thefashionsocietyh.editorx.io/website-11/page-3-mwe