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

What is Framer? Join the Community
Return to index
Daniel Caine
Posted Jan 21 - Read on Facebook

Hey guys, any idea how to target a specific layer which has been created in a loop? I have named some layers in a loop through 'name: "page" + (i + 1)' but when I go to use the layer outside the loop, it cannot be found - despite the fact it appears and is named correctly in the layer tree.

Any help is much appreciated!

Code:

5 Comments

Andrew Nalband

You're going to want to use "sublayersByName" - that returns an array of all matching layers with that name. Since that array only contains one item, you can get it by appending [0]

http://share.framerjs.com/ahmjq76bgshs/

Ben Rodenhäuser

Another option would be to store all the layers you create during the loop in an array. Then you can target them by addressing that array. See here: http://share.framerjs.com/93fopr95oziu/

Andreas Wahlström

This is a pretty common issue! This module lets you do $get('page1') https://github.com/awt2542/Find-for-Framer

Daniel Caine

Thanks guys

Paddu Raghavan

I vote on Ben's answer. Having an array and storing layers inside it works

Read the entire post on Facebook