$('.navigation-main').find('li').has('ul').children('a').on('click', function (e) {
e.preventDefault();
// Collapsible
$(this).parent('li').not('.disabled').not($('.sidebar-xs').not('.sidebar-xs-indicator').find('.navigation-main').children('li')).toggleClass('active').children('ul').slideToggle(250);
// Accordion
if ($('.navigation-main').hasClass('navigation-accordion')) {
$(this).parent('li').not('.disabled').not($('.sidebar-xs').not('.sidebar-xs-indicator').find('.navigation-main').children('li')).siblings(':has(.has-ul)').removeClass('active').children('ul').slideUp(250);
}
});
以上是我的javascript。
HTML部分是,
<div class="sidebar-category sidebar-category-visible">
<div class="category-content no-padding">
<ul class="navigation navigation-main navigation-accordion">
<li class="active"><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/site/index"><i class="icon-home4"></i> <span>Dashboard</span></a></li>
<li>
<a href="#"><i class="icon-cogs"></i><span>Settings</span></a>
<ul>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/core/institution/create">Add Institution Details</a></li>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/core/academic/create">Academic Details</a></li>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/site/import">Student Import</a></li>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/site/employeeimport">Employee Import</a></li>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/core/privilege/create">Privileges</a></li>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/core/assignclass/create">Assign <?php echo Yii::app()->params['course']; ?>s</a></li>
<li><a href="<?php echo Yii::app()->request->baseUrl; ?>/index.php/site/users">Users</a></li>
</ul>
</li>
<li>
代码适用于我的导航面板。但在将页面重新加载到选定的子菜单后,所有的手风琴都将关闭。导航面板代码以单独的文件写入并包含在每个页面中。我希望活动类在重定向后设置为最近单击的菜单