简体   繁体   English

Rails 3-如何在嵌套表单属性中设置不同的id(html属性)

[英]Rails 3 - How to set different id (html attribute) in nested form attributes

I'm developing a rails 3.0.9 app, I'm using "accept nested attributes for" to add dynamically new "child" items to its "parentW. the thing is every child has the same id (html attribute), and I need every child with its own id, because I need to make some jquery functions to work with them. 我正在开发Rails 3.0.9应用程序,正在使用“接受嵌套属性”将动态的新“子项”项添加到其“ parentW”中。问题是每个子项都具有相同的id(html属性),我需要每个孩子都有自己的ID,因为我需要制作一些jquery函数来使用它们。

Is there a way to achieve this? 有没有办法做到这一点?

Tanks for your help 坦克为您提供帮助

Adding an new element to a Nested Form was handled brilliantly in a Railscast . Railscast中巧妙地将新元素添加到嵌套表单中。 In it, Ryan uses javascript to replace the ID attribute with something more meaningful. 在其中,Ryan使用javascript用更有意义的内容替换了ID属性。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM