帮助解决此 Rails 代码(选择和 javascript)
我需要在每个选项和 JavaScript 中进行选择,
**select...%>**
<% @buscar.each do |j|%>
<option value="<%= j.cedula_tutor1 %>" onclick="Datos2('j.cedula_tutor1');">
<%= j.cedula_tutor1 %>
</option>
<%end%>
**</select>**
这是我在 Rails 中所做的:
<%=select("cedula_tutor1", "nombre",Tutore.all.collect{|u| [u.cedula_tutor1,u.nombre_tutor1]},{}, {:onchange => "Datos2('j.cedula_tutor1'))"})%>
当然,这不起作用,因为 j.cedula_tutor1
在循环之外。我怎样才能做到呢?我只想调用一个 JavaScript 函数,将 j.cedula_tutor
作为参数。
I need to have a select with options and JavaScript in each one,
**select...%>**
<% @buscar.each do |j|%>
<option value="<%= j.cedula_tutor1 %>" onclick="Datos2('j.cedula_tutor1');">
<%= j.cedula_tutor1 %>
</option>
<%end%>
**</select>**
This is what I have made in rails:
<%=select("cedula_tutor1", "nombre",Tutore.all.collect{|u| [u.cedula_tutor1,u.nombre_tutor1]},{}, {:onchange => "Datos2('j.cedula_tutor1'))"})%>
Of course that doesn't work because the j.cedula_tutor1
is outside the loop. How can I make it? I just want to call a JavaScript function giving the j.cedula_tutor
as parameters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该用它来扩展你的循环。或者只是创建一些类变量以通过子实例的
parent
属性访问它。或诸如来电者之类的东西。you should extend your loop with it. or just make some class variable to access it via
parent
attribute of child instance. or something like caller.