Reputation: 1584
I'm implementing links in a google map feature of my site. Each link connects to a different venue in my site. In order to do this, I've been using Javascript and following the Google API tutorials.
the place variable is generated by Javascript and I would like to have it be the name of the link. However, the notation:
contentString = '<%=link_to '+place.name+'%>';
yields the result: +place.name+ (underlined since it is a link)
I'm doing something wrong and it's probably very simple but am not sure what it is. Any help would be appreciated.
Upvotes: 0
Views: 88
Reputation: 29599
The simple answer is you cant do this. Rails views has no access to javascript variables when they are compiled. The simplest way to accomplish this is to use js to change the text of the link (which is not applicable to what you're trying to do). You should just build your string without using rails helpers
contentString = '<a href="/some/path">' + place.name + '</a>'
Upvotes: 1