jquery - Twitter Bootstrap - Open one menu, automatically closes another -


okay, first of all, here's site: http://songfreek.com

upon site loading, "user" menu opened, , rest closed. now, when open menu (lets "radio dj" tab), both "user" menu , "radio dj" menu opened.

i'd make if clicked "radio dj" menu, "user" menu close, , on.

here's code "user" menu "radio dj" menu.

                        <!-- user -->                         <li class="nav-header">                             <a href="#" data-toggle="collapse" data-target="#usermenu">                                 <font color="#333333">user</font> <i class="icon-angle-down"></i>                             </a>                             <ul style="list-style: none;" class="collapse in" id="usermenu">                                 <li class="active"><a href="#"><i class="icon-home"></i> home</a></li>                                 <li><a href="#"><i class="icon-envelope-alt"></i> messages <span class="badge badge-info">4</span></a></li>                                 <li><a href="#"><i class="icon-cogs"></i> settings</a></li>                                 <li><a href="#"><i class="icon-comment"></i> shoutbox</a></li>                                 <li><a href="#"><i class="icon-user"></i> staff list</a></li>                                 <li><a href="#"><i class="icon-flag"></i> infractions</a></li>                                 <li><a href="#"><i class="icon-exclamation-sign"></i> rules &amp; regulations</a></li>                                 <li><a href="#"><i class="icon-off"></i> logout</a></li>                             </ul>                         </li>                          <!-- radio dj -->                         <li class="nav-header">                             <a href="#" data-toggle="collapse" data-target="#radiodjmenu">                                 <font color="#34ccff">radio dj</font> <i class="icon-angle-down"></i>                             </a>                             <ul style="list-style: none;" class="collapse" id="radiodjmenu">                                 <li><a href="#">information &amp; stats</a></li>                                 <li><a href="#">dj says</a></li>                                 <li><a href="#">request line</a></li>                                 <li><a href="#">timetable</a></li>                                 <li><a href="#">banned songs</a></li>                             </ul>                         </li> 

ok, lets go 3 3 on songfreek.com...

you can close other open menus assigning function collapse 'show' event this:

    $('.collapse').on('show', function (e) {          // hide open menus         $('.collapse').each(function(){           if ($(this).hasclass('in')) {               $(this).collapse('toggle');           }         });     }) 

when menu open, 'show' event triggered. other menus open contain in class collapse('toggle') can used close them.

i've updated bootply @ http://bootply.com/61710 demonstrate this.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -