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

What is Framer? Join the Community
Return to index
Chris Camargo
Posted May 27 - Read on Facebook

I'm really scratching my head here... Why am I getting the correct value for i placed in the html here, but every time I click to retrieve my layer's name, I get the last number iterated?


Chris Camargo

Chris Camargo

Actually, this doesn't seem to have anything to do with the iterator value. If I insert my own data, clicking each box always returns the value of the last layer pushed to the array.

Koen Bok

Yes, this is a confusing part about javascript:

To get around this, use the layer argument from the callback:

Koen Bok

In the simplest language, the layer value in your click handler references to whatever layer is at the click moment, not when you set the handler up.

Chris Camargo

Ah, so simple! Thanks, Koen.

Antonio Krämer Fernandez

layer name is a different property that you have to set. Maybe this also helps you:

Read the entire post on Facebook