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

What is Framer? Join the Community
Return to index
Benny Chew
Posted Aug 04 - Read on Facebook

I'm prototyping a tile based game (Bingo). Any ideas how to create a button event for let's say 25 tiles and being able to retrieve their ID (number from 0 to 24) on click. Not having to create separate 25 functions. I've tried a for loop, it worked, but I couldn't manage to retrieve the ID. I need this ID for an array I have. I couldn't find this in the examples, also searching was tricky to find. Thanks!


Min-Sang Choi

Try using “this”. It’ll tell current object’s properties.

//Object is an array, and syntax is under the loop

Object = new Layer blahblahblah

Obejct.on Events.Click,->


Benny Chew

Thanks Min-Sang Choi will try!

Koen Bok

Here is a simple example:

Benny Chew

Great! Thanks Koen Bok it worked. The Framer.js community is awesome! I didn't know you could pass the layer obj as a 2nd parameter in the click event.

Benny Chew

Just learned you can't use "id", it's a protected property perhaps. Have to use something like "buttonID" like in your example. Good to know.

Andreas Wahlström

you can also use this.buttonId instead of adding a clickedLayer parameter.

Ed Chao

here's an example of something somewhat similar. It's a photogrid populated with data from an object array. Data can be retrieved on an event.

Benny Chew

Thanks for sharing Ed Chao, will definitely check it out!

Read the entire post on Facebook