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

What is Framer? Join the Community
Return to index
Tom Columbus
Posted Nov 03 - Read on Facebook

So I have a layer in Framer with an HTML property. In the HTML I have a link. I want that link to trigger a function in Framer when it is clicked. Does anyone know how to do this?


Derek Nguyen

I think one way to do it is to give your <a> a class like <a class="link">, then get a reference to that class in the dom:
`link = document.getElementsByClassName('link')[0]`
and attach onclick to it:
`Events.wrap(link).on Events.Click, (e) -> print`

But I think you could use TextLayer for this though? so you don't have to go around Framer like this

edit: use Framer's Events.wrap()

Tom Columbus

Thanks for your answer - it makes sense but alas, it didn't work.

I'm not familiar with the Events.wrap().
I know you can wrap() scroll content but that's all I know of.

I can easily make the whole Text layer selectable but I want just a word, mid paragraph.

Tom Columbus

Got it! Add an ID then use framer's querySelector to bind it to an object. Note, the parent layer must be receiving events. If I remove the onClick from the layer that contains the HTML it does not "find" the HTML anchor.

Read the entire post on Facebook