简体   繁体   English

使用带有link_to的工具提示(Ruby on Rails 3.2.3)

[英]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. 但是,我想使用link_to命令为菜单中定义的链接执行工具提示。 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: 这是bootstrap.js.coffee中的JS代码:

$(".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. 我是一名学生,仍然在学习很多关于Rails,Twitter Bootstrap,CSS3,HTML5等的知识。我做了很多网络搜索,但没有找到任何我理解的例子。 Basically there is nothing that says directly that I can do a tooltip within a link_to statement that worked. 基本上没有什么能直接说明我可以在link_to语句中做一个工具提示。

Any help would be appreciated. 任何帮助,将不胜感激。

This way: 这条路:

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

update: 更新:

It's ruby 1.9 syntax. 这是ruby 1.9语法。 For 1.8 it would be 对于1.8,它将是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM