How to set a title for a text field?

I know this is something simple, but I'm stuck. I have several forms in my rails3 application that need to add tooltips using tipsy . The text in the tooltips should be defined in the \ original-title header, but I just can't figure it out how to set it for a text box.

<%= f.text_field :what %>

gives me

<input id="name_which" name="name[which]" size="30" type="text">

and I just can't figure 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 is defined

$(window).load(function() {
$('#form-example [title]').tipsy({trigger: 'focus', gravity: 'w'});

});

I know that this is something basic, and I am ashamed of myself. Thanks in advance.

+3
source share
2 answers

It's pretty simple, pass it as an option:

<% = f.text_field: what,: title= > " % >

html : class,: id ..

+6

:

<%= f.text_field :what, :title => 'whatever' %>
+9

Source: https://habr.com/ru/post/1791821/


All Articles