Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Tooltips with link_to (Ruby on Rails 3.2.3)

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.

like image 908
xxx Avatar asked May 16 '12 21:05

xxx


1 Answers

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'
like image 142
ok32 Avatar answered Sep 24 '22 09:09

ok32