rails bootstrap popover click不起作用

时间:2012-11-28 15:45:08

标签: ruby-on-rails twitter-bootstrap click popover

我正在尝试使用twitter bootstrap example中的弹出框,因此当您单击按钮时会出现,当您单击它时它会消失。

我有app.js

//= require bootstrap-tooltip.js
//= require bootstrap-popover.js
$(function () {
$('.popover-test').popover();

});

在我看来_fof.html.erb

<button class="popover-test" id="button1" data-content="Popover Content">
    <%= 'ciao' %>
</button>

但是popover仅在鼠标悬停时出现,当我继续前进时它会消失。 我是否要在js中实现on_click功能?

1 个答案:

答案 0 :(得分:0)

默认情况下,弹出窗口是由鼠标悬停触发的,而不是通过点击触发的。如果向下滚动链接到的Bootstrap文档网页,您将看到一个选项列表,包括如何设置触发器。

Name: trigger
Type: string
Default: 'click'
Description: how popover is triggered - click | hover | focus | manual

所以称之为:

$('.popover-test').popover({target: "click"});
相关问题