问题描述
我知道这很简单,但是我被困住了.我在rails3应用程序中有几种表单,需要使用 tipsy 向其中添加工具提示.工具提示中的文本应以title \ original-title确定,但我无法弄清楚如何将其设置为text_field.
I know that is something simple, but I'm stuck.I have a several forms in my rails3 app to which I need to add tooltips, by using the tipsy. The text in tooltips should be determined in title\original-title, but I just can't figure it out, how to set it for text_field.
<%= f.text_field :what %>
给我
<input id="name_which" name="name[which]" size="30" type="text">
我只是想不通,在哪里放置标题文本.
and I just can't figure it out, where to put the title text.
例如,用html编写的这个效果很好
For example, this one in html works fine
<input type="text" name="tooltipform" title="Tooltip text">
在application.js中,它由
In application.js it is determined by
$(window).load(function() {
$('#form-example [title]').tipsy({trigger: 'focus', gravity: 'w'});
});
我知道这是基本的事情,我为自己感到羞耻.先感谢您.
I know that is something basic and I'm ashamed of my self. Thank you in advance.
推荐答案
这很简单,将其作为选项传递:
It's quite simple, pass it as an option:
<%= f.text_field:what,:title =>工具提示文本%>
<%= f.text_field :what, :title => "Tooltip text %>
还可以将其他html属性设置为此,例如:class,:id等.
Other html attributes can also be set as this, such as :class, :id, etc.
这篇关于如何设置text_field的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!