admin管理员组文章数量:1336644
I'm using Bootstrap v2.3.2 with a collapse element.
My accordion looks like this:
<div class="accordion" id="accordion">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
<strong><i class="icon-chevron-down"></i>Search options</strong>
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
Hello
</div>
</div>
</div>
</div>
If i collapse the element #collapseOne by clicking on it, no problem.
But if i call the function$("#collapseOne").collapse('show');
, the element will hide except of showing, but only on first call and only if i don't collapse the element clicking on it before that. I think i forgot a HTML element, but i can't see any difference into DOM...
Fiddle : click on the 'click me' button without clicking on collapsible element before.
Already try: add $accordion.collapse({toggle:true}) () but it didn't worked...
I'm using Bootstrap v2.3.2 with a collapse element.
My accordion looks like this:
<div class="accordion" id="accordion">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
<strong><i class="icon-chevron-down"></i>Search options</strong>
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
Hello
</div>
</div>
</div>
</div>
If i collapse the element #collapseOne by clicking on it, no problem.
But if i call the function$("#collapseOne").collapse('show');
, the element will hide except of showing, but only on first call and only if i don't collapse the element clicking on it before that. I think i forgot a HTML element, but i can't see any difference into DOM...
Fiddle : click on the 'click me' button without clicking on collapsible element before.
Already try: add $accordion.collapse({toggle:true}) (https://github./twbs/bootstrap/issues/5859) but it didn't worked...
Share Improve this question asked Feb 27, 2014 at 10:49 GetzGetz 4,0636 gold badges37 silver badges52 bronze badges2 Answers
Reset to default 3$accordion.collapse({toggle:false})
fixes toggle issue, but on wrong element.
You need to fix on #collapseOne
$("#collapseOne").collapse({toggle:false});
FIDDLE
I solved this for my solution in my template... Just like that:
$(document).ready(function() {
$(".panel-body").collapse({ 'toggle': false });
});
本文标签: javascriptCall of bootstrap collapse(39show39) hide element only the first timeStack Overflow
版权声明:本文标题:javascript - Call of bootstrap collapse('show') hide element only the first time - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742409274a2469456.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论