7

I have been successful in creating a tooltip for text using code similar to:

<a href="#" rel="tooltip" title="something">text on page</a>

However I would like to do a tooltip for a link defined in a menu using the link_to command. I have included the statement I would like a tooltip to appear for:

<li><i class="icon-edit"></i>&nbsp;<%= link_to current_user.first_name+' '+current_user.last_name, edit_user_path(current_user) %></li>

Here is the JS code in bootstrap.js.coffee:

$(".tooltip").tooltip()
$("a[rel=tooltip]").tooltip()

I am a student still learning a lot about Rails, Twitter Bootstrap, CSS3, HTML5, etc. I have done many web searches but have not found any examples of this that I understood. Basically there is nothing that says directly that I can do a tooltip within a link_to statement that worked.

Any help would be appreciated.

4

1 回答 1

23

This way:

link_to 'Text', '/link', title: 'some title', rel: 'tooltip'

update:

It's ruby 1.9 syntax. For 1.8 it would be

link_to 'Text', '/link', :title => 'some title', :rel => 'tooltip'
于 2012-05-16T21:36:06.527 回答