使用带有link_to的工具提示(Ruby on Rails 3.2.3) [英] Using Tooltips with link_to (Ruby on Rails 3.2.3)

查看:69
本文介绍了使用带有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>

但是我想使用link_to命令为菜单中定义的链接做一个工具提示。我已经包含了我希望工具提示出现的声明:

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>

这是bootstrap.js.coffee中的JS代码:

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

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

我还是一名学生,他还在学习很多关于Rails,Twitter Bootstrap,CSS3,HTML5等的知识。我做了很多网络搜索但是我没有找到任何我理解的例子。基本上没有什么可以直接说明我可以在link_to语句中做一个工具提示。

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.

推荐答案

这样:

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

更新:

这是ruby 1.9语法。对于1.8,它将是

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

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

这篇关于使用带有link_to的工具提示(Ruby on Rails 3.2.3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆