Twitter Bootstrap cant stop a dropdown from closing on click

前端 未结 2 1147
南方客
南方客 2020-12-10 07:34

I have looked at the other questions similar and tried many of the solutions, but none have worked. Here is the issue, this is a mini login form for the top banner. I need

2条回答
  •  感动是毒
    2020-12-10 07:54

    I was having the same problem with an accordion/toggle sub-menu that was nested within a dropdown-menu in Bootstrap 3. Borrowed this syntax from the source code to stop all collapse toggles from closing the dropdown:

    $(document).on(
        'click.bs.dropdown.data-api', 
        '[data-toggle="collapse"]', 
        function (e) { e.stopPropagation() }
    );
    

    You can replace [data-toggle="collapse"] with whatever you want to stop closing the form, e.g. another class or another data property.

提交回复
热议问题