Search code examples
jquerytwitter-bootstrap-3

Dropdown-menu on close callback


Hi I'm trying to execute a function if the dropdown-menu of bootstrap is closed. Surely I can just add the function call if the menu dropdown-toggle is click. But my concern is what if the user didn't click the dropdown-toggle but instead clicked outside or on other element. The dropdown-menu closes if I click on other element.

Is there a way or is there any callback on bootstrap if the dropdown-menu is closed?

I tried this but its not working

$('.dropdown-menu').on('shown.bs.collapse', function(e) {
    alert("Close");
});

Solution

  • Try with this parameter:

    $('.dropdown-menu').on('hidden.bs.dropdown', function(e) {
        alert("Close");
    })