3

ここに示すように、ツールチップ機能を実装しようとしています: http://twitter.github.com/bootstrap/javascript.html#tooltips Ruby on Rails 3 の Bootstrap-sass gem を使用します。動作しません (テキストの上にカーソルを置いてもテキストが表示されません):

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 に答える