문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top