Why is my dropdown menu with Bootstrap not working?

前端 未结 6 1071
野性不改
野性不改 2021-02-08 07:54

In my Rails application, I have the following code for a dropdown menu:

&l
6条回答
  •  隐瞒了意图╮
    2021-02-08 08:24

    The solution lies in the order you import the javascript dependencies.

    This is what I had initially in my application.js

    //= require jquery
    //= require jquery_ujs
    //= require bootstrap
    //= require bootstrap-sprockets
    //= require turbolinks
    //= require_tree 
    

    When I removed bootstrap-sprockets i my dropdown worked. However, I did not want to remove bootstrap-sprockets. So My new order looked like this;

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

    Then, to be safe, I had to clean and pre-compile assets by running the following;

    rake assets:clean
    bundle exec rake assets:precompile
    

    This worked for me.

提交回复
热议问题