我正在使用bootstrap 2来构建带有可折叠菜单的wordpress主题,并且一切正常,但是当我单击菜单中的新项目时,打开的项目不会关闭。任何的想法?
可以忽略php :)谢谢。
PS:当我用纯HTML测试时,它工作得很好
<div class="accordion-group">
<div class="accordion-heading"><a href="#<?=$catItem->slug;?>" class="accordion-toggle show-info" data-toggle="collapse" data-parent="#<?=$generalActiveMenu;?>" id="<?=$catItem->term_id;?>"><?=$catItem->name;?></a></div>
<div id="<?=$catItem->slug;?>" class="accordion-body collapse">
<div class="accordion-inner">
<div id="<?=$generalActiveMenu;?>1" class="accordion">
<? $subCategory = new $Category();
$subCategory->getCategoryList($catItem->term_id); /* get sub category of each product */
foreach($subCategory->catList as $key => $subCatItem) {
?><div class="accordion-group">
<div class="accordion-heading">
<a href="#<?=$subCatItem->slug;?>" class="accordion-toggle show-info" data-toggle="collapse" data-parent="#<?=$generalActiveMenu;?>1" id="<?=$subCatItem->term_id;?>"><?=$subCatItem->name;?></a>
</div>
<div id="<?=$subCatItem->slug;?>" class="accordion-body collapse">
<? if(get_posts('category_name='.$subCatItem->slug)) {
?><div class="accordion-inner">
<ul class="nav nav-list">
<? $Post->postCat = $subCatItem->term_id;
$Post->getPostList();
foreach ($Post->postList as $key => $postItem) {
?><li id="<?=$postItem->post_name;?>"><a href="<?=$postItem->post_name;?>"><?=$postItem->post_title;?></a></li><?
} ?>
</ul>
</div><?
} ?>
</div>
</div><?
}
?>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
我可能错了,但你可以尝试:
$('#myAccordianTab').collapse({
toggle: true
})
请查看此链接以获取更多信息: http://getbootstrap.com/2.3.2/javascript.html#collapse
这可以帮助您正确构建并解释切换(或折叠)功能