Using Tooltips with link_to (Ruby on Rails 3.2.3)

2020-03-18 04:15发布

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.

1条回答
放荡不羁爱自由
2楼-- · 2020-03-18 04:32

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'
查看更多
登录 后发表回答