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?
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.