问题
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 %>
gives me
<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.
For example, this one in html works fine
<input type="text" name="tooltipform" title="Tooltip text">
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.
回答1:
It's quite simple, pass it as an option:
<%= f.text_field :what, :title => "Tooltip text %>
Other html attributes can also be set as this, such as :class, :id, etc.
回答2:
Try with:
<%= f.text_field :what, :title => 'whatever' %>
来源:https://stackoverflow.com/questions/4984028/how-to-set-title-for-text-field