Code:
$(function() {
return $(".side-menu .nav .dropdown").on('show.bs.collapse', function() {
return $(".side-menu .nav .dropdown .collapse").collapse('hide');
});
});
Unintended behavior:
Outer container collapses (probably because before shown, he hide all) sometimes within' these milisecs between show.bs.collapse and shown.bs.collapse.
How do I pass $(".side-menu .nav .dropdown") that is triggering .on(...) to the inner function call, so I could hide the others? Or hide only the ones that is already show?
thisinside the callback function toon()(e.g.var $nav = $(this);). Another item of note: drop thosereturnstatements. If you added code to the DOM-ready handler after what you have here, it wouldn't run because you are ending execution withreturn. Also,show.bs.collapseis fired when the element starts to be shown, not after it is shown. You may want to useshown.bs.collapseinstead..collapse's before ending theshowtoshown(the call is onshowas you can see) transition, what causes the outter container to "close" (because there are no items expanded for these milisecs).