小编krn*_*njn的帖子

使用数组在Rails link_to中添加锚点选项

我正在使用数组为我的rails link_to标签生成路径,似乎无法弄清楚如何添加锚选项.这是我的link_to标签:

<%= link_to pluralize(post.comments.count, 'comment'), [post.postable, post] %>

<%= link_to "Leave a comment", [post.postable, post] %>
Run Code Online (Sandbox Code Playgroud)

由于我正在为帖子使用多态关联(并且它们是嵌套路由),因此我不能简单地使用routes.rb文件中的资源助手生成的路径.

以前,我能够在自动生成的路径上使用锚选项,因为我没有使用与此模型的多态关联.这是看起来像:

<%= link_to pluralize(post.comments.count, 'comment'), project_post_path(@project, post, {anchor: 'comments'}) %>

<%= link_to "Leave a comment", project_post_path(@project, post, {anchor: 'new-comment'}) %>
Run Code Online (Sandbox Code Playgroud)

有关如何在使用数组生成url时将锚标记返回到link_to标记的任何提示?提前致谢.

anchor ruby-on-rails erb link-to

4
推荐指数
1
解决办法
912
查看次数

在Initialize上显示Twitter Bootstrap工具提示

我基本上想要在有人第一次到达页面时显示工具提示,但是当他们将鼠标悬停在页面上(或页面上的其他工具提示)后,它会返回其默认的悬停行为.发生这种情况似乎有一个错误,但效果不佳.目前我使用$('div#id').tooltip('show')命令加载工具提示,但我似乎无法弄清楚如何将其恢复为默认的悬停行为.更糟糕的是,如果我为特定div编写悬停功能以在"显示"和"隐藏"之间切换,那么它就是错误的.

您可以在此网站上查看此行为:http://rework.herokuapp.com/organizations,在"如何运作"部分下.

这是HTML代码:

<div class="row center works">

   <div class="of center"><img alt="Step 1" class="center step init" data-placement="bottom" id="step1" rel="tooltip" src="/assets/works/step1.png" data-original-title="People who are driven to find meaningful work apply to the ReWork Talent Pool."></div>

   <div class="of center"><img alt="Step 2" class="center step" data-placement="bottom" id="step2" rel="tooltip" src="/assets/works/step2.png" data-original-title="ReWork screens applicants for skills, experience, values, and accomplishments."></div>

   <div class="of center"><img alt="Step 3" class="center step" data-placement="bottom" id="step3" rel="tooltip" src="/assets/works/step3.png" data-original-title="You engage ReWork for a role you need filled, and ReWork hand-selects …
Run Code Online (Sandbox Code Playgroud)

jquery ruby-on-rails twitter-bootstrap

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

ruby-on-rails ×2

anchor ×1

erb ×1

jquery ×1

link-to ×1

twitter-bootstrap ×1