简体   繁体   English

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

[英]bootstrap/javascript dropdown menu not working on heroku

I have and app that functions fine on my local machine, however, when i deploy it to heroku the dropdown menu on the navbar refuses to work... here is the code for the dropdown 我的应用程序在我的本地计算机上运行良好,但是,当我将其部署到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> 

I have already set all of the assets to precompile, and I have tried doing it by hand. 我已经将所有资产设置为预编译,并且我尝试手动进行。 Not sure why it isn't working 不知道为什么它不起作用

EDIT: 编辑:

application.js application.js

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

you nee to add the document.ready function: 您需要添加document.ready函数:

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

instead of 代替

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

Regards! 问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM