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

What is Framer? Join the Community
Return to index
Thomas Offinga
Posted May 10 - Read on Facebook

I'm trying to figure out a way to get the index of a layer inside an array, but I'm not sure what the proper syntax is.

buttons = []
for i in [0..4]
button = new Layer

buttons.push(button)

button.onClick ->
print button.i
print buttons

Is there any way to figure out what the position if of the button within the array?

4 Comments

Kees Plattel

button.onClick ->
print this.index

Or:

button.name = "button_ " + i

button.onClick ->
print this.name

Marc Krenn

_.indexOf(buttons,this)

Pascal Verstegen

Go drunk Thomas you're home

Игорь Растворов

index - 1

Read the entire post on Facebook