Javascript Twitter Bootstrap.popover()函数在Rails中不起作用
我正在尝试开始为Rails使用Twitter引导。Javascript Twitter Bootstrap.popover()函数在Rails中不起作用,javascript,ruby-on-rails,twitter-bootstrap,Javascript,Ruby On Rails,Twitter Bootstrap,我正在尝试开始为Rails使用Twitter引导。popover()函数根本不起作用。什么也没发生 layouts/application.html.erb: <!DOCTYPE html> <html> <head> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "http://twitter.github.com/bootstrap/
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>
<li>
<a data-placement="below"
class="btn danger span2"
data-content="This is a test"
href="#"
rel="popover">+ Test</a>
</li>
我的文件的一部分:
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
我还尝试在我的application.js
文件中复制/粘贴twipsy.js
和popover.js
,并在我的layouts/application.html.erb中调用它,方法是:
<%= javascript_include_tag "application" %>
我错过了什么?有什么想法吗?问题在于您使用的选择器:
$("a[rel=popover]")
jQuery选择器匹配整个rel
属性,并且根据a,Rails向rel
标记添加额外的属性,如nofollow
请尝试改用此选择器:
$("a[rel*=popover]")
问题在于您正在使用的选择器:
$("a[rel=popover]")
jQuery选择器匹配整个rel
属性,并且根据a,Rails向rel
标记添加额外的属性,如nofollow
请尝试改用此选择器:
$("a[rel*=popover]")
jQuery也包括在您的页面上吗?jQuery也包括在您的页面上吗?嗨,Jared,谢谢您的回复。实际上,$([rel=popover])可以很好地使用rails。我在jquery库的链接中出错。我用替换了它,它工作得很好。你好,贾里德,谢谢你的回复。实际上,$([rel=popover])可以很好地使用rails。我在jquery库的链接中出错。我把它换成了,它工作得很好