[SOLVED] The use of the $w.at is absolutely cryptic !

I have a repeater with some repeated items and I want have access to the local scope pf the repeater.

Better, I don’t click ANYTHING but I want only have access to the proprieties of the elements in the i-mo item, HOW DO I DO IT ?

For example I want change the color of a box in the 3d item!
https://www.wix.com/corvid/reference/$w.Repeater.html#repeated-item-scope
BUT, after I get the itemData and relative index with the following:

$w("#myRepeater").onItemReady( ($item, itemData, index) {...}

how can I select the item with n-index ?

Eg. $item(“#box1”, 3).backgroundcolor = “red” in order to select the 3d items.

PLease
thx in advance
Mauro

HI Mauro. You can do something like this.

const arrayOfContexts = [];
$w('#repeater').onItemReady(($item, itemData, index) => {
  arrayOfContexts.push($item);
});

arrayOfContexts[3]('#box1').style.backgroundcolor = 'red';

Hi @andriis sorry, but it didn’t work.

«TypeError: arrayOfContexts[3] is not a function»

Hi @andriis I understood your approach, the best if it could work, but the only way I found was the following, that’s to insert into the loop with a condition.

This works :

$w.onReady( () => {

$w("#repeater1").onItemReady(($item, itemData, index) => {
console.log(index)
if (index===3) {$item("#box1").style.backgroundColor = 'red'}
})

})

Is possible to get your approach to work ?
Thansk
Mauro

Hello Mauro. I’ve created simple example site to show how to use this approach. On button click it changes the text in previous repeater container. https://andriis.wixsite.com/mysite-6/blank-1

import uuid from 'uuid';

$w.onReady(function () {
 //generate array with 5 elements
 const dataForRepeater = Array(5).fill('example').map(() => ({
        _id: uuid() //generate random id
    }));
    $w('#repeater1').data = dataForRepeater;
 const arrayOfContexts = [];
    $w('#repeater1').onItemReady(($item, itemData, index) => {
        arrayOfContexts.push($item);
        $item('#button1').onClick(event => {
 if (arrayOfContexts[index - 1]) { //if context exists, change it's text
                arrayOfContexts[index - 1]('#mytext').text = `I was changed from  container with index ${index}`;
            }
        });
    });
});