Bootstrap 3: how to make head of dropdown link clickable in navbar

前端 未结 15 842
暗喜
暗喜 2020-12-07 09:23

I\'m using the default navbar and a couple of the list items are dropdowns. I\'m not able to click the link that triggers the dropdown. I know that I could just add a duplic

15条回答
  •  自闭症患者
    2020-12-07 10:27

    This enables the link in the top-level menu of the dropdown when it's opened and disables it when closed, with the only drawback of apparently having to "tap" twice outside of the dropdown to close it in mobile devices.

    $(document).on("page:load", function(){
        $('body').on('show.bs.dropdown', function (e) {
            $(e.relatedTarget).addClass('disabled')
        });
        $('body').on('hide.bs.dropdown', function (e) {
            $(e.relatedTarget).removeClass('disabled')
        });
    });
    

    Note this assumes the "standard" markup and Turbolinks (Rails). You can try with $(document).ready(...)

提交回复
热议问题