Basically, I have a dropdown menu that works individually and when you click on the button it opens, if you click on it again it closes. Now if i was to open another one at the same time then I have the issue of they are both open.
Now I'm certain that it must be really simple to close them before the isntances are open. However if you look at this fiddle: http://jsfiddle.net/g2c10t53/
If i was to simply remove all occurances with some JQuery:
$('.dropdown-toggle').attr('aria-expanded',false);
$('.dropdown-menu').removeClass('open');
Although this would in theory make it work, I cannot now click on the same button I have opened to close it. It simply does nothing, so I could remove:
$('.dropdown-toggle').attr('aria-expanded',false);
But then if i was to start swapping between buttons I have a problem where I have to click twice to open the other dropdown menu which I do not want to do.
I've been trying to find a way where I can go through .each()
occurrence of $('.dropdown-toggle')
to check if it's attribute ID is equal to the one that is clicked and if not remove the occurrence of said dropdown and change the aria-expaned to false but i've had no luck.
Any suggestions? Thanks.