Twitter bootstrap stop propagation on dropdown open

后端 未结 6 1649
清酒与你
清酒与你 2020-12-10 10:50

I have a twitter bootstrap dropdown inside a div with the plugin jOrgChart.

The problem I\'m having is that when I click the button to open the dropdown menu it also

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 11:16

    Building on Joe's answer, this includes the normal dropdown functionality of closing on the next click.

    $("#orgchart").jOrgChart({ chartElement: '#chart' });
    
    $("div#chart div.btn-group > a.dropdown-toggle, .dropdown-menu li a").click((e) => {
        e.stopPropagation();
        $('.dropdown-menu').toggle();
    
        // close on next click only
        $(window).one("click", () => $('.dropdown-menu').toggle());
    });​
    

提交回复
热议问题