【发布时间】:2012-01-29 09:37:27
【问题描述】:
我正在尝试开始使用 Twitter Bootstrap for Rails。 popover() 函数根本不起作用。什么都没发生。
layouts/application.html.erb:
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "http://twitter.github.com/bootstrap/1.4.0/bootstrap-buttons.js" %>
<%= javascript_include_tag "http://twitter.github.com/bootstrap/1.4.0/bootstrap-twipsy.js" %>
<%= javascript_include_tag "http://twitter.github.com/bootstrap/1.4.0/bootstrap-popover.js" %>
<%= csrf_meta_tags %>
<script>
$(function () {
$("a[rel=popover]")
.popover({
offset: 10
})
.click(function(e) {
e.preventDefault()
})
});
</script>
</head>
<body>
<%= yield %>
</body>
</html>
这是我views/test/test.htlm.erb的一部分:
<li>
<a data-placement="below"
class="btn danger span2"
data-content="This is a test"
href="#"
rel="popover">+ Test</a>
</li>
我的 Gemfile 的一部分:
gem 'rails', '3.1.3'
gem 'jruby-openssl'
gem 'json'
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-rails'
end
我还尝试将twipsy.js 和popover.js 复制/粘贴到我的application.js 文件中,并在我的layouts/application.html.erb 中调用它:
<%= javascript_include_tag "application" %>
我错过了什么?有什么想法吗?
【问题讨论】:
-
您的页面是否也包含 jQuery?
标签: javascript ruby-on-rails twitter-bootstrap