Hi I have the following:
= link_to @place.name, '#', onclick: 'get_maps(#{@location_string});'
I'm currently trying to link to a javascript call with a rails variable argument but for some reason the rails variable @location_string
isn't being passed to the javascript call with the variable in it. Currently it's being rendered as a string:
<a href="#" onclick="get_maps(#{@location_string});">3308 Kanaina Ave</a>
Any thoughts on how to solve this?
You need to put:
= link_to @place.name, '#', :onclick => "get_maps('#{@location_string}');"
The onclick is a parameter of link_to.
And the parameter inside get_maps should go inside ''.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With