两个不同的 Bootstrap accordion 相互触发

uwopmtnx  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(160)

正如你可以在例子bootlint是好的,所有的ID是唯一的,但两个不同的可折叠 accordion 触发对方。仍在寻找解决方案。
示例:http://codepen.io/bertanyaman/pen/NNOLyG

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-6">
            <div id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingOne">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#accordion"
                                href="#collapseOne" aria-expanded="true"
                                aria-controls="collapseOne">Collapsible Group Item #1</a>
                        </h4>
                    </div>
                    <div id="collapseOne" class="panel-collapse collapse in"
                        role="tabpanel" aria-labelledby="headingOne">
                        Anim pariatur cliche reprehenderit...
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingTwo">
                        <h4 class="panel-title">
                            <a class="collapsed" data-toggle="collapse"
                                data-parent="#accordion" href="#collapseTwo"
                                aria-expanded="false" aria-controls="collapseTwo">Collapsible Group Item #2</a>
                        </h4>
                    </div>
                    <div id="collapseTwo" class="panel-collapse collapse"
                        role="tabpanel" aria-labelledby="headingTwo">
                        Anim pariatur cliche reprehenderit...
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingThree">
                        <h4 class="panel-title">
                            <a class="collapsed" data-toggle="collapse"
                                data-parent="#accordion" href="#collapseThree"
                                aria-expanded="false" aria-controls="collapseThree">Collapsible Group Item #3</a>
                        </h4>
                    </div>
                    <div id="collapseThree" class="panel-collapse collapse"
                        role="tabpanel" aria-labelledby="headingThree">
                        Anim pariatur cliche reprehenderit...
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div id="accordion2" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingOne2">
                        <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#accordion2"
                                href="#collapseOne2" aria-expanded="true"
                                aria-controls="collapseOne2">Collapsible Group Item
              #1</a>
                        </h4>
                    </div>
                    <div id="collapseOne2" class="panel-collapse collapse in"
                        role="tabpanel" aria-labelledby="headingOne2">
                        Anim pariatur cliche reprehenderit...
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingTwo2">
                        <h4 class="panel-title">
                            <a class="collapsed" data-toggle="collapse"
                                data-parent="#accordion2" href="#collapseTwo2"
                                aria-expanded="false" aria-controls="collapseTwo2">Collapsible Group Item #2</a>
                        </h4>
                    </div>
                    <div id="collapseTwo2" class="panel-collapse collapse"
                        role="tabpanel" aria-labelledby="headingTwo2">
                        Anim pariatur cliche reprehenderit...
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingThree2">
                        <h4 class="panel-title">
                            <a class="collapsed" data-toggle="collapse"
                                data-parent="#accordion2" href="#collapseThree2"
                                aria-expanded="false" aria-controls="collapseThree2">Collapsible Group Item #3</a>
                        </h4>
                    </div>
                    <div id="collapseThree2" class="panel-collapse collapse"
                        role="tabpanel" aria-labelledby="headingThree2">
                        Anim pariatur cliche reprehenderit...
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
8oomwypt

8oomwypt1#

我看到你在CodePen上的代码示例使用的是TWBS 4-alpha 2版本的css和js。如果你恢复到TWBS 3.3.6(和JQuery 1),那么你的代码就可以工作了。
请看前面的问题25359335,它是JSFiddle
我将此工作代码复制到您的Codepen,它也坏了,但随后我恢复到3.3.6,它又工作了。
这是V4中的known bug

<sorry> :( </sorry>

相关问题