[英]ERB tag within link_to_function JavaScript call
I need to dynamically set which id a JavaScript call uses, as I have multiples rendered on each page, I'm trying to use 我需要动态设置JavaScript调用使用的ID,因为我在每个页面上都有多个呈现,因此我尝试使用
<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? 您不能像这样在JavaScript中嵌入erb标签吗? If not, how else do I do it?
如果没有,我该怎么办?
You're already in a ruby method. 您已经采用了红宝石方法。 So you don't need to embed ERB.
因此,您无需嵌入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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.