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

What is Framer? Join the Community
Return to index
Brent Bonet
Posted Feb 16 - Read on Facebook

I have a bunch of layers that are basically list items. Imported from Photoshop. Each item is a group. I can get a click when I use offersLayers.item1.on EventsClick etc, but I'll like to loop to add the click listener as so

offersLayers = Framer.Importer.load "imported/offers"

for k, v of offersLayers
v.on Events.Click, -> onOfferSelected(event, layer)

onOfferSelected = (event, layer) ->

When I do this I get ReferenceError: Can't find variable: layer. Is there not a way to do this?


Benjamin Den Boer

Hey Brent Bonet, there is, but you need to use "v" as the function argument within your click event, on "onOfferSelected". Otherwise, within your layer event, you're never actually targeting the layer from within your loop.

Benjamin Den Boer

Here's an even easier way to accomplish this. :-)

Read the entire post on Facebook