Question

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?

Was it helpful?

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

OTHER TIPS

The solution is actually pretty simple and the one marked as correct comes pretty close, here is how you can disable the toggle mechanism:

$('#myDiv').on('hide.bs.collapse', function (e) {
  return isMyDivEnabled(); // true or false
}).on('show.bs.collapse', function (e) {
  return isMyDivEnabled(); // true or false
});

Cheers

Chris

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top