[英]bootstrap/javascript dropdown menu not working on heroku
我的應用程序在我的本地計算機上運行良好,但是,當我將其部署到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();
問候!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.