admin管理员组文章数量:1391925
I have a Bootstrap Accordion with a check box inside each of the accordion panel. When I check the checkbox inside of a panel, its parent should collapse and the next panel should open.
I am using the jQuery icheck plugin for styling checkboxes. So what I can do to make the accordion panels collapse? FIDDLE
$('.item1').on('ifChecked', function(event){
});
I have a Bootstrap Accordion with a check box inside each of the accordion panel. When I check the checkbox inside of a panel, its parent should collapse and the next panel should open.
I am using the jQuery icheck plugin for styling checkboxes. So what I can do to make the accordion panels collapse? FIDDLE
$('.item1').on('ifChecked', function(event){
});
Share
Improve this question
edited Nov 13, 2014 at 14:41
alex
7,50811 gold badges60 silver badges113 bronze badges
asked Nov 13, 2014 at 14:23
RaihanRaihan
4,0313 gold badges25 silver badges41 bronze badges
3 Answers
Reset to default 3If I understood you correctly, you might want something like that:
Updated code:
// Toggle
$('.item1').on('ifChecked', function(event){
$("#collapseOne").collapse("hide");
});
$('.item2').on('ifChecked', function(event){
$("#collapseTwo").collapse("hide");
});
$('.item3').on('ifChecked', function(event){
$("#collapseThree").collapse("hide");
});
$("#collapseOne").on("hidden.bs.collapse", function(e){
$("#collapseTwo").collapse("show");
});
$("#collapseTwo").on("hidden.bs.collapse", function(e){
$("#collapseThree").collapse("show");
});
$("#collapseThree").on("hidden.bs.collapse", function(e){
$("#collapseOne").collapse("show");
});
First fiddle here: http://jsfiddle/sap1ruq2/1/
UPDATED fiddle here: http://jsfiddle/bstjmdLp/
Let me know if this was what you needed!
You could do something like this in your case
$('input').on('ifChecked', function(event){
$(this).parents('.panel').first().next().find('.panel-heading a').click();
});
Updated with a fiddle: http://jsfiddle/Lq07ysbq/11/
Ideally you should use the JS API provided by the plug-in. In this case, use 'hide' and 'show' options (http://getbootstrap./javascript/#collapse). I've updated your fiddle here: http://jsfiddle/catalyst156/Lq07ysbq/13/
$('.item1').on('ifChecked', function(event){
$(this).parents('.panel-collapse').collapse('hide');
$('#collapseTwo').collapse('show');
});
Off the top of my head, I can't e up with a general solution for opening the next panel so for now, the specific id is used.
本文标签: javascriptHow to Collapse bootstrap accordion by click check box inside itStack Overflow
版权声明:本文标题:javascript - How to Collapse bootstrap accordion by click check box inside it - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744701038a2620563.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论