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

What is Framer? Join the Community
Return to index
James Matchett
Posted Oct 22 - Read on Facebook

Can someone tell me how I can loop through a bunch of layers (cta1, cta2, cta3..cta25) and give it the same on click event?

3 Comments

Joshua Tucker

Hey James! Put them in an array and loop through them.

ctas = [cta1, cta2...]

for cta in ctas
cta.on Events.Click, ->
Do whatever

Or if all those cta layers have the same superLayer

for cta in superLayer.subLayers
cta.on Events.Click, ->
Do whatever

Jörg Lehmann

or create a custom class which has a click event already:

Andrew Nalband

Also, if you give them all the same superLayer, you can get an array of them with theSuperLayerName.subLayers the trick here is the use of the "@" symbol which means "this" http://share.framerjs.com/p2ct126qti4w/

Read the entire post on Facebook