html - Bootstrap DIVs sliding in JQuery -
i using bootstrap manage ui. have 3 divs - first div : col-lg-10. second div : col-lg-36. third div : col-lg-1. third div has hidden div (inner_third div) has data display.
first , second divs visible. third div collapsible , expands (and show() inner_third div) based on hyperlink click second div.
i able expand third div (and show() inner_third div) ease. stuck when again collapsing third div (and hide() inner_third div) again. hide() of inner_third div happens before collapsing starts , want hide() after collapse.
collapsed state : first div : col-lg-10. second div : col-lg-36. third div : col-lg-1 (with inner_third div hidden).
expanded state : first div : col-lg-10. second div : col-lg-19. third div : col-lg-19 (with inner_third div visible).
below 1 page code -
<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="scripts/jquery-1.9.0.js"></script> <script src="scripts/bootstrap.js"></script> <script src="scripts/jquery-ui-1.10.4.js"></script> <link href="content/bootstrap.css" rel="stylesheet" /> </head> <body> <div class="row"> <div class="col-lg-10" style="height:300px;background-color: #fa5d4e" id="content"> <h2>getting started</h2> <p> asp.net mvc gives powerful, patterns-based way build dynamic websites enables clean separation of concerns , gives full control on markup enjoyable, agile development. </p> <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?linkid=301865">learn more »</a></p> </div> <div class="col-lg-36" style="background-color:yellow;height:300px" id="menu1"> <h2>get more libraries</h2> <p>nuget free visual studio extension makes easy add, remove, , update libraries , tools in visual studio projects.</p> <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?linkid=301866">learn more »</a></p> <a href="#" id="showdetailssection">details</a> </div> <div class="col-lg-1" style="background-color:blue;height:300px;padding:0px" id="menu2"> <div id="menu2div" style="display:none;background-color:green;overflow:auto;margin:0px;height:300px;padding:0px"> <h2>web hosting</h2> <p>you can find web hosting company offers right mix of features , price applications.</p> <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?linkid=301867">learn more »</a></p> </div> </div> </div> </body> </html> <script type="text/javascript"> $('#showdetailssection').click(function () { var $col1 = $('#menu1'); var $col2 = $('#menu2'); if ($col1.hasclass('col-lg-36')) { $col1.switchclass('col-lg-36', 'col-lg-19'); $col2.switchclass('col-lg-1', 'col-lg-19'); $('#menu2div').show(0); } else { $col1.switchclass('col-lg-19', 'col-lg-36'); $col2.switchclass('col-lg-19', 'col-lg-1'); $('#menu2div').hide(); } }); </script>
bootstrap has event fires after collapse complete. instead of on click
hide, use hidden.bs.collapse
:
$('#showdetailssection').on('hidden.bs.collapse', function () { $('#menu2div').hide(); });
Comments
Post a Comment