Already Visible collapse gets closed when .collapse('show') is called
Created by: lightningdev45
I have a panel-collapse in a dropdown menu that I want to to open up if the panel contains a link with the ".active" css class. To make this work I close all collapses and then open up the one I want to open when the dropdown is hidden (note, all of the collapses start open by default):
$('#dropdown').on('hide.bs.dropdown', function (event) {
$('.panel-collapse.in').not(":has(.active)").collapse('hide');
$("#dropdown .active").parent("ul").parent(".panel-collapse").collapse('show');
});
However this doesn't work. The .collapse('show') is actually closing the open panel for some reason. However if I use more specific css and don't explicitly show the panel I want to have open unless it is closed, it works:
$('#dropdown').on('hide.bs.dropdown', function (event) {
$('.panel-collapse.in').not(":has(.active)").collapse('hide');
$("#dropdown .active").parent("ul").parent(".panel-collapse:not(.in)").collapse('show');
});