views:

138

answers:

1

I need to dynamically set which id a javascript call uses, as I have multiples rendered on each page, I'm trying to use

<p id="add_rider_link_section_<%= section.id %>"><%= link_to_function("Add a Rider",
"Element.remove('add_rider_link_section_' + <%= section.id %> + '' ); Element.show('add_rider')") %></p>

It's failing on

"Element.remove('add_rider_link_section_' + <%= section.id %> + '' );

Can you not embed erb tags within javascript like that? If not, how else do I do it?

A: 

You're already in a ruby method. So you don't need to embed ERB.
You just have to use ruby.

<p id="add_rider_link_section_<%= section.id %>">
    <%= link_to_function("Add a Rider",
            "Element.remove('add_rider_link_section_" + section.id + "'); Element.show('add_rider')") %>
</p>
Damien MATHIEU
What a fool, thanks very much
Nick