bootstrap/javascript下拉菜单在heroku上不起作用

bootstrap/javascript dropdown menu not working on heroku

本文关键字:heroku 不起作用 下拉菜单 javascript bootstrap      更新时间:2024-07-03

我有一个在本地机器上运行良好的应用程序,但当我将其部署到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

您需要添加document.ready函数:

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

而不是

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

问候!