Search code examples
javascripttwitter-bootstraptoggle

Disable Twitter Bootstrap collapse toggling


I'm using Twitter Boostraps component collapse to reveal some fields which is done by clicking in another field. However, if I click the same field again the other fields get hidden again (i.e toggling).

What I want is to disable the toggling so that the fields won't hide when clicking the field a second time. Could this be done easily with some built-in methods or do I need to dive deep into the js file to change it myself?


Solution

  • You should be able to do something as simple as..

    $('#myDiv').on('hide.bs.collapse', function (e) {
      preventDefault(e);
    })
    

    This handles the Bootstrap 3 hide.bs.collapse event, and prevents the DIV from being hidden again.

    Demo: http://bootply.com/75650