twitter-bootstrap Bootstrap 折叠无法正常工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13183150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 15:38:10  来源:igfitidea点击:

Bootstrap collapse not working properly

twitter-bootstrapaccordioncollapse

提问by mickeymoon

I have created an accordion with bootstrap collapse. There are certain elements in accordion that alternate on expansion on click of the particular element. The following markup is created:

我创建了一个带有 bootstrap 折叠功能的手风琴。手风琴中的某些元素会在单击特定元素时在扩展时交替出现。创建了以下标记:

    <div class="accordion" id="accordion2">

        <div class="accordion-group">
            <div class="accordion-heading">
                <a class="accordion-toggle" href="#collapse-0" id="0" data-toggle="collapse" data-parent="#accordion2">
                   User Visits
                </a>
            </div>
            <div id="collapse-0" class="accordion-body collapse in">
                <div class="accordion-inner">
                    Collapsible <br/>
                    Collapsible <br/>
                </div>
            </div>
        </div>

        <div class="accordion-group">                   
            <div class="accordion-heading">
                <a class="accordion-toggle" href="#collapse-1" id="1" data-toggle="collapse" data-parent="#accordion2">
                    Points
                </a>
            </div>                  
            <div id="collapse-1" class="accordion-body collapse">
                <div class="accordion-inner">
                    Collapsible <br/>
                    Collapsible <br/>
                </div>
            </div>
        </div>

    </div>

The problem is that after the page loads the first click on a particular element results in successful expansion of the .accordion-body .collapseblock but successive calls do not result into any expansion.

问题是在页面加载后第一次单击特定元素会导致.accordion-body .collapse块的成功扩展,但连续调用不会导致任何扩展。

The expansion results due to addition of a class called indynamically. Even on the successive clicks on accordion elements the inspection shows the flipping of the inclass as it should be but in spite of that the element doesn't expand.

由于添加了in动态调用的类而导致的扩展结果。即使连续点击手风琴元素,检查in也会显示类的翻转,但尽管如此,元素并没有展开。

Please suggest what could be the problem.

请建议可能是什么问题。

回答by mickeymoon

I've figured out the problem. Actually the collapse jquery plugin requires the inclusion of bootstrap-transitionplugin. I tried with either 'only' bootstrap-collapsethat caused the above problem or a full bootstrap.jsthat caused other issues.

我已经想通了问题所在。实际上,折叠 jquery 插件需要包含bootstrap-transition插件。我尝试使用bootstrap-collapse导致上述问题的“仅”或bootstrap.js导致其他问题的完整。