javascript - Bootstrap collapse - opening multiple accordions at the same time -


i've got point accordions open @ same time - see http://www.bootply.com/go4t29ryyf

when click on "tab1" "tab1s" open, when click on "tab2" "tab2s" open - great! cant open "tab1s & tab2s" @ same time, works when close 1 of tabs first before opening another. issue js cant work out.

$(function () {          var $active = true;          $('.panel-title > a').click(function (e) {             e.preventdefault();         });          $('.number1-collapse').on('click', function () {             if (!$active) {                 $active = true;                 $('.panel-title > a').attr('data-toggle', 'collapse');                 $('.number1').collapse('hide');             } else {                 $active = false;                 $('.number1').collapse('show');                 $('.panel-title > a').attr('data-toggle', '');             }         });           $('.number2-collapse').on('click', function () {             if (!$active) {                 $active = true;                 $('.panel-title > a').attr('data-toggle', 'collapse');                 $('.number2').collapse('hide');             } else {                 $active = false;                 $('.number2').collapse('show');                 $('.panel-title > a').attr('data-toggle', '');             }         });     }); 

i've tidied code , changed using toggle method instead of having various flags. problem sharing active flag between them. here improved code , bootply:

$(function () {     $('.panel-title > a').click(function (e) {         e.preventdefault();     });      $('.number1-collapse').on('click', function () {         $('.number1').collapse('toggle');     });      $('.number2-collapse').on('click', function () {         $('.number2').collapse('toggle');     }); }); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -