The menu must remain open while I click anywhere on the document or screen, but when I click on the dropdown of a second menu, it should close the previous menu, and also need to open and close by clicking the dropdown.
My bootstrap code:
$(function() {
$('.dropdown.opened')
.on({
"shown.bs.dropdown": function() {
this.closable = ($('.dropdown.open').length > 1) ? true : false
},
"click": function() { this.closable = true;
if (($('.dropdown.open').length > 1)) {
$('.dropdown.opened').removeClass('open');
}
},
"hide.bs.dropdown": function() { return this.closable; }
});
});
See that in the rule I'm checking if there is at least 1 open, then it changes the behavior, dropdown, however it should close all the menus when I click on any other or the same dropdown, and start the dropdown process again .