soundasleep / jquery-dropdown

Bootstrap-style dropdowns with some added features and no dependencies.
Other
767 stars 268 forks source link

Add a way to prevent hide action. #71

Closed saibotsivad closed 9 years ago

saibotsivad commented 9 years ago

In our app development, we found it necessary to have a way to block the hiding of the dropdown programmatically for particular cases. This is what we are using in our code, and it seems like a thing that could be useful to have pulled in.

The way we use it is, for example, in some function where we don't have access to event to block propagation:

function doSomeActionWhileDropdownIsOpen() {
    var dropdown = $('#dropdown-panel');
    dropdown.addClass('prevent-hide');
    // do things (e.g. allow user to click places)
    dropdown.removeClass('prevent-hide')
}
saibotsivad commented 9 years ago

Hey @claviska, any chance you'd merge this? It's pretty handy.

claviska commented 9 years ago

I see where it could be useful, but I think it would be better to do this through the show method. As is, you could just as easily override the menu's style using the .prevent-dropdown class :)