最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using Tooltips with link_to (Ruby on Rails 3.2.3) - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question asked May 16, 2012 at 21:23 Pamela Cook - LightBe CorpPamela Cook - LightBe Corp 4,0526 gold badges52 silver badges88 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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'
发布评论

评论列表(0)

  1. 暂无评论