1

Я пытаюсь реализовать smooth scroll. Я попытался использовать этот gem, чтобы установить его. Он не работает, и я не могу понять, почему. Я установил его правильно? Правильно ли я это использовал? Я предполагаю, что он установлен неправильно.jquery-smooth-scroll-rails не работает

EDIT: Для его установки я добавил gem "jquery-smooth-scroll-rails", "~> 0.0.3" в мой Gemfile, побежал gem install jquery-smooth-scroll-rails, а затем bundle install.

Gemfile

group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 
    gem 'asset_sync' 
    gem 'fontello-rails' 
    gem "jquery-smooth-scroll-rails", "~> 0.0.3" 

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

    gem 'uglifier', '>= 1.0.3' 
end 

Это мой код:

home.html.erb

<% provide(:title, 'Questions About College? CollegeANSWERZ') %> 

<div id="home_css"> 

<h1 id="top">Better College Reviews <span class="icon-ok"></span></h1> 
<h1>Information You Want <span class="icon-ok"></span></h1> 
<h1>Good Advice <span class="icon-ok"></span></h1> 
<h1 id="collegeanswerz">Collegeanswerz.</h1> 

<%= image_tag("pitt.png", size: "336x440", id: "picture") %> 

<div id="bottom"> 
<div id="nav"> 
    <ul> 
     <li id="why_its_better" class="nav_element">Why it's Better</li> 
     <li></li> 
     <li id="how_it_works" class="nav_element">How it Works</li> 
     <li></li> 
     <li id="our_philosophy" class="nav_element">Our Philosophy</li> 
     <li></li> 
     <li id="about_me" class="nav_element">About Me</li> 
    </ul> 
</div> 

<div id="details" class="well"> 
    <section id="why_its_better_section"> 
     <h2 class="well">Why it's Better </h2> 

     <h3>BETTER COLLEGE REVIEWS</h3> 
     <p>As a college applicant, there are a lot of specific things that you want to know.</p>  </section> 

    <section id="how_it_works_section"> 
     <h2 class="well">How It Works</h2> 

     <p>Answering Questions - how answering questions works</p> 
     <ul> 
      <li>There's about 60 questions per school. Each question takes about a minute or two to answer. Whatever you have time for and feel comfortable with is much appreciated!</li> 

    </section> 

    <section id="about_me_section"> 
     <h2 class="well">About Me</h2> 
    </section> 

</div> 
</div> 


</div> 

home.js

$(document).ready(function(){ 
     $("#contact").click(function() { 
      $("#top_area").hide("fast"); 
      $(".idea_bar").show("fast"); 
     }); 
     $("#close").click(function() { 
      $(".idea_bar").hide("fast"); 
      $("#top_area").show("fast"); 
     }); 

     $("#why_its_better_section, #how_it_works_section, #our_philosophy_section, #about_me_section").hide(); 
     $("#why_its_better").click(function() { 
      $("#how_it_works_section, #our_philosophy_section, #about_me_section").hide(); 
      $("#why_its_better_section").show(); 
      $("#details").smoothScroll(); 
     }); 
     $("#how_it_works").click(function() { 
      $("#why_its_better_section, #our_philosophy_section, #about_me_section").hide(); 
      $("#how_it_works_section").show(); 
      $("#details").smoothScroll(); 
     }); 
     $("#our_philosophy").click(function() { 
      $("#why_its_better_section, #how_it_works_section, #about_me_section").hide(); 
      $("#our_philosophy_section").show(); 
      $("#details").smoothScroll(); 
     }); 
     $("#about_me").click(function() { 
      $("#why_its_better_section, #how_it_works_section, #our_philosophy_section").hide(); 
      $("#about_me_section").show(); 
      $("#details").smoothScroll(); 
     }); 

     $("#search_field").autocomplete({ 
      source: [ 
      "Adelphi University", 
      "American University", 
      "Wofford" ] 
     }); 
     $("#search_text").submit(function() { 
      if ($("#search_field").val() == "Adelphi University") 
      { 
       window.location.href = "/adelphi-university"; 
       return false; 
      } 
     }); 


}); 

ответ

-1

Вы, наверное, забыл добавить JavaScript библиотеки в вашем application.js

Добавьте следующие два, чтобы включить их:

//= require jquery.easing 
//= require jquery.smoothScroll 
+0

Это дало мне файл не найдена ошибка. Я попытался удалить часть jquery.easing и только часть jquery.smoothScroll, но это все равно дало мне файл, который не найден. –

Смежные вопросы