Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top