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

What is Framer? Join the Community
Return to index
Christian Schaf
Posted Jan 12 - Read on Facebook

[SOLVED]

Hi guys, I have a Problem. I created a module called Marker. It contains a class and extends from Layer. Now i want handle a click on it self.No clicks on a single Marker will recognized. What can I do? The file is located in ./app/modules

Project: https://github.com/cschaf/tourist-app

11 Comments

Koen Bok

Ah, good old scoping issues. Once the event gets called, this isn't the Marker instance anymore. You can fix it with a "fat arrow": http://webapplog.com/understanding-fat-arrows-in-coffeescript/

Koen Bok

(This will work the same in ES6, the next version of Javascript)

Christian Schaf

hmm cant fiddle it out I get the error: Uncaught TypeError: Marker.on is not a function. I change it to this.on Events.Click =>
print "marker clicked" or this.on Events.Click, =>
print "marker clicked". Maybe its not allowed to use the "on"

Koen Bok

Let me make you an example. I can't really use your code because it's missing indentation, but I think it will be clear.

Koen Bok

Wait no, multiple things might be going wrong. Could you share your code with the "Share" button?

Christian Schaf
Christian Schaf
Koen Bok

Ah, you need to call super before you use the .on function :-/

Christian Schaf

Thank you very much <3

Koen Bok

Bonus tip: you can make your options optional by doing:

`options.width ?= 50`

That way they will only get set if you don't pass it yourself.

Andrew Nalband

Hi Christian Schaf can you attach your project? Cut and paste is tough with facebook and coffescript since whitespace matters and facebook doesn't honor it

Read the entire post on Facebook