3

我正在尝试实现工具提示功能,如下所示:http: //twitter.github.com/bootstrap/javascript.html#tooltips使用 Ruby on Rails 3 的 Bootstrap-sass gem。我已经完成了以下操作,但它没有'不起作用(当我将鼠标悬停在文本上时,文本不会出现):

在宝石文件中:

gem 'bootstrap-sass', '2.1'

在 application.js 中:

//= require bootstrap

在 show.js.erb 中:

$('#example').tooltip(options);

在 show.html.erb 中:

<a href="#" id="example" title="first tooltip" data-placement="right">
  hover over me</a>

为什么这不起作用?

应用程序.js:

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

视图/布局/application.html.erb:

<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js?ver=1.4.0"></script> 
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
  <%= yield %>
  <%= render 'layouts/footer' %>
  <%= debug(params) if Rails.env.development? %>
 </div>
</body>
</html>

宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.7'
gem 'bootstrap-sass', '2.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
end

group :development do
  gem 'annotate', '2.5.0'
end
4

1 回答 1

2

你需要这个:

// Loads all Bootstrap javascripts
//= require bootstrap

来自https://github.com/thomas-mcdonald/bootstrap-sass

于 2013-05-26T20:44:27.817 回答