bootstrap / javascript下拉菜单无法在heroku

时间:2016-04-13 21:18:09

标签: javascript jquery ruby-on-rails twitter-bootstrap heroku

我有和app在我的本地机器上正常运行,但是,当我将它部署到heroku时,导航栏上的下拉菜单拒绝工作...这里是下拉列表的代码

 <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Learning Wellness <span class="caret"></span> </a>
        <ul class="dropdown-menu">
          <li><% yield (:exercise)%><%= link_to "Exercise", exercise_path%></li>
          <li><% yield (:eating_healthy)%><%= link_to "Eating Healthy", eating_healthy_path%></li>
          <li><% yield (:safety)%><%= link_to "Safety", safety_path%></li>
          <li><% yield (:health_awareness)%><%= link_to "Health & Awareness", health_awareness_path%></li>
        </ul>
      </li>

      <script type="text/javascript">
        $('.dropdown-toggle').dropdown()
      </script>

我已经将所有资产都设置为预编译,并且我已尝试手动完成。不知道为什么它不起作用

编辑:

的application.js

//= require turbolinks
//= require_tree .
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require bootstrap
//= require jquery.slick
//= require initialize

1 个答案:

答案 0 :(得分:0)

你需要添加document.ready功能:

$( document ).ready(function() {
    $('.dropdown-toggle').dropdown();
});

而不是

$('.dropdown-toggle').dropdown();

问候!