Rails标题汉堡包导航无法正常工作

时间:2018-04-02 04:07:01

标签: jquery ruby-on-rails twitter-bootstrap d3.js turbolinks

我无法在我的标题中获取汉堡包下拉列表来处理我的rails应用程序。

要注意,我已经使用D3在应用程序中实现了一个图表,因此我禁用了turbolinks。是否可以使用此设置进行下拉菜单?

的javascript / application.js中

//= require jquery
//= require jquery-ui/datepicker
//= require jquery_ujs
//= bootstrap-sprockets
//= require d3
// require turbolinks
//= require_tree .

样式表/ application.css

 *= require_tree .
 *= require jquery-ui/datepicker
 *= require_self
 */

我的共享/ _header.html.erb

<!-- <header role="banner"> -->
      <!-- <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> -->
      <nav class="navbar navbar-default">
        <div class="container-fluid">
          <div class="navbar-header">
            <!-- Burger -->
            <button type="button"
              class="navbar-toggle collapsed"
              data-toggle="collapse"
              data-target="#bs-example-navbar-collapse-1">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <!-- Burger -->
            <!-- Home Link -->
            <%= link_to "Athletes Den", root_path, class: "navbar-brand" %>
            <!-- Home Link -->
          </div>
  <!-- Header link and Inside the burger when collapsed-->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
              <li class="active"><%= link_to "Home", root_path %></li>
            </ul>
<!-- no db table so cannot use form for so use form tag and tag-->
            <%= form_tag(search_dashboards_path,
                          class: "navbar-form navbar-left",
                          role: "search") do %>
              <div class="form-group">
                <%= text_field_tag :search_name, nil, placeholder:
                        "Search for friends", class: "form-control"  %>
              </div>
              <%= submit_tag "Search", class: 'btn btn-default' %>
            <% end %>


            <ul class="nav navbar-nav navbar-right">
              <% if user_signed_in? %>
              <li><%= link_to "My Lounge", user_exercises_path(current_user) %></li>
              <li><%= link_to "Sign out", destroy_user_session_path, method: :delete %></li>
              <div class="navbar-right">
                <p class="navbar-text">Signed in as <%= "#{current_user.email}" %></p>
              </div>
              <% else %>
              <li><%= link_to "Sign in", new_user_session_path %></li>
              <li><%= link_to "Sign up", new_user_registration_path %></li>
              <% end %>

            </ul>
          </div>
          <!-- end of navbar-collapse collapse  -->
        </div>
        <!-- end of container fluid  -->
      </nav>
    <!-- </header> -->

布局/ application.html.erb

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>WorkoutApp</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag 'application', media: 'all' %>
    <%= javascript_include_tag 'application' %>
  </head>

  <body>

    <%= render 'shared/header' %>
    <%= render 'shared/main' %>
    <!-- main is the error messages -->
    <%= render 'shared/footer' %>
  </body>
</html>

的Gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'

gem 'jquery-rails'

gem 'jquery-ui-rails', '~> 5.0.5'

gem 'd3-rails', '~>4.1.0'

gem 'will_paginate-bootstrap', '~> 1.0.1'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
# gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass', '~>3.3.6'

gem 'devise', '~>4.3.0'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '3.5.1'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'guard', '~> 2.14.0'
  gem 'guard-rspec', '~> 4.7.2'
  gem 'guard-cucumber', '~>2.1.2'
end

group :test do
  gem 'capybara', '2.7.1'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

0 个答案:

没有答案