This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Dániel Korpai
Posted Apr 06 - Read on Facebook

Hey :)

I've started to work more heavily with for-loop, but got really stuck at a point.

I created 4 cards with a for-loop and added a cardinfo layer for each of them with a 'parent: card' attribute. Then, I grab all of them and put them in an array (called cards) like this: 'cards.push(card). So far so good. :)

The problem starts when I want to modify all cardinfo layers, which are child of the card layers. So when I use 'for card in cards' I can only edit the first cardinfo layer, not all of them. :(

Do you have an idea, how can I modify all child layers of a layer which is in a for-loop? It would be awesome to hear some guesses. Thank you! :)

2 Comments

Ian McClure

So cardInfo is a variable that is created in the for loop. When you edit cardinfo, you edit the variable that was created.

You need to either add the cardinfo layer as a property
or just access it under the children of the card layer.
Add card.info = cardInfo after you make the layer then in your loop you would set card.info.visible to false or not add the property and set card.children[1].visible to false.

Steve Ruiz

Hey, you're calling the cardInfo variable left over from the loop, rather than the property you've given to the object you pushed into the cards array on line 83. Instead, in your loop there at the bottom, call card.cardInfo to get the layer stored in that object. Just replacing 'cardInfo' with 'card.cardInfo' will work.

Read the entire post on Facebook