Topic: how can I place a link_to inside a javascript function

Hi, I have a javascript function which returns some html which I would like to include a link to my show method of my controller but it does not seem be working...

marker.openInfoWindowHtml("<%= link_to(person.full_name, person_path(person)%>" + '<br>' + age + '<br>' + town)

If I just output the person.full_name or the person_path in the html I get the correct output string, but if you combine the two and add it to a link_to it cant cope.

Thanks!

Re: how can I place a link_to inside a javascript function

hi...
i need the solution to the same problem....did u got the answer??...
how can i call a javascript inside marker.openInfoWindowHtml??

i require something like:
marker.openInfoWindowHtml('<script>here goes my javascript include</script><table>whatever</table>')

Any help would be much appreciated.
thanks

Re: how can I place a link_to inside a javascript function

Have you find solution at  this problem?

Re: how can I place a link_to inside a javascript function

I've never done a link_to in this way, but I would think that the link_to still needs to say what controller and action you want to use. You may need something like this:

<%= link_to person.full_name, {:controller => "person", :action => "show"} %>

Last edited by terrance19 (2008-12-02 17:08:31)

Re: how can I place a link_to inside a javascript function

Try using escape_javascript.

If I've helped you out with something, feel free to recommend me on working with rails.