call javascript function from haml link_to

Sandah Aung picture Sandah Aung · Oct 28, 2012 · Viewed 26.1k times · Source

I would like to invoke a javascript function (without JQuery) when the onclick even fires from a link_to tag in haml. How can I do this?

Answer

edouardbriere picture edouardbriere · Oct 28, 2012

Here’s how to do it using Rails link_to in haml:

= link_to "my link", "", :onclick => "my_function(); return false"