twitter-bootstrap – 你如何让Twitter Bootstrap手风琴保持一个组打开?

我试图使用手风琴和折叠插件使用Twitter引导模拟Outlook栏,到目前为止我得到了折叠和手风琴工作,但目前允许所有部分折叠。

我想限制它,以便一个只有一个总是显示

这里是我正在工作的一个http://jsfiddle.net/trajano/SMT9D/,我认为它在某处沿线

$('#accordions').on('hide',function (event) {
  console.warn("HIDE TRIGGERED,check if trying to hide the active one if so stop");
})

解决方法

这里有一个简单的方法

新引导3

Bootstrap 3的JsFiddle

Bootstrap 3的代码

$('.panel-heading a').on('click',function(e){
    if($(this).parents('.panel').children('.panel-collapse').hasClass('in')){
        e.stopPropagation();
    }
    // You can also add preventDefault to remove the anchor behavior that makes
    // the page jump
    // e.preventDefault();
});

代码检查点击的元素是否是当前显示的(通过类“in”),如果它有“in”类,它停止隐藏进程。

已弃用的Bootstrap 2

JsFiddle为Bootstrap 2。

Bootstrap 2的代码

$('.accordion-toggle').on('click',function(e){
    if($(this).parents('.accordion-group').children('.accordion-body').hasClass('in')){
        e.stopPropagation();
    }
    // You can also add preventDefault to remove the anchor behavior that makes
    // the page jump
    // e.preventDefault();
});

注意:如果要在手风琴上附加更多点击事件,请小心,因为e.stopPropagation()将阻止在检查后发生的事件。

相关文章

Bootstrip HTML 查询搜索常用格式模版 <form class=&...
如何在按钮上加红色数字 您可以使用Bootstrap的badge组件来在...
要让两个按钮左右排列,你可以使用 Bootstrap 的网格系统将它...
是的,可以将status设置为布尔类型,这样可以在前端使用复选...
前端工程师一般用的是Bootstrap的框架而不是样式,样式一般自...
起步导入:<linkrel="stylesheet"href="b...