帮助 Rails Collection_Select [编辑]
我一直在尝试在我的应用程序中实现 this jquery 插件。我需要帮助尝试输出一些内容像这样
<select name="user[university_id]" id="user_university_id" class="selectable">
<option value="1" title="uni1">Uni1</option>
<option value="2" title="uni2">Uni2</option>
</select>
通过使用 Rails 助手...问题是助手似乎永远不会向选项标签输出标题属性..这对于这个插件至关重要,
请帮忙, 提前致谢
编辑: 我当前的 Rails 代码
<%= f.collection_select(:university_id,University.all,:id,:name) %>
只是输出
<select name="user[university_id]" id="user_university_id">
<option value="1">Uni1</option>
<option value="2">Uni2</option>
</select>
所以基本上我需要的是一种将 title 属性添加到我的选项中的方法。
I have been trying to implement this jquery plugin to my app.I need help trying to output something like this
<select name="user[university_id]" id="user_university_id" class="selectable">
<option value="1" title="uni1">Uni1</option>
<option value="2" title="uni2">Uni2</option>
</select>
by using a rails helper...the problem is the helpers never seem to output a title attribute to the option tags.. which is critical for this plugin
please help,
thanks in advance
Edit:
my current rails code is
<%= f.collection_select(:university_id,University.all,:id,:name) %>
which simply outputs
<select name="user[university_id]" id="user_university_id">
<option value="1">Uni1</option>
<option value="2">Uni2</option>
</select>
So basically what I need is a way to also add title attribute to my options.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你不走rails helper路线,你可以用jQuery添加它:
You could just add it with jQuery, if you don't go the rails helper route: