2016-10-25 64 views
0

這裏有添加,查看和編輯pages.when我點擊添加和查看頁面的頁面變得活躍,父母也變得活躍。但是當我點擊編輯頁面顯示在查看頁面中,家長沒有變得活躍。 這裏是我的看法頁子頁面沒有變得活躍

<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-bed"></i> Room Management <b class="fa fa-plus dropdown-plus"></b> </a> 
     <ul class="dropdown-menu"> 
      <li class="<?php if($active_mn=='add_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_class"> <i class="fa fa-caret-right"></i>Add Class</a> </li> 
      <li class="<?php if($active_mn=='view_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_class"> <i class="fa fa-caret-right"></i>View Class</a> </li> 
      <li class="<?php if($active_mn=='add_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_rooms"> <i class="fa fa-caret-right"></i>Add Rooms</a> </li> 
      <li class="<?php if($active_mn=='view_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_rooms"> <i class="fa fa-caret-right"></i>View Rooms</a> </li> 
     </ul> 
     </li> 

從視圖頁面我要去編輯頁面,這裏是代碼

<td><a class="btn btn-success active" href="<?php echo base_url() ?>admin/edit_hostel/<?php echo $row->id ?>"> Edit </a> </td> 

這裏,我不得不使用菜單中的腳本變得活躍

<script> 
$(document).ready(function() { 
var url = window.location; 
$('ul.dropdown-menu a[href="' + this.location.pathname + '"]').parent().addClass('open active'); 
$('ul.dropdown-menu a').filter(function() { 
    return this.href == url; 
}).parent().parent().parent().addClass('open active'); 
}); 
</script> 

回答

0

嘗試contains pseudoselector

var url = window.location; 
    $('ul.dropdown-menu a[href*="' + this.location.pathname + '"]').parent().addClass('open active').closest('li').addClass('open active'); 
}); 
+0

仍然看起來一樣 –

+0

沒有變化happened..and我改變了我的代碼喜歡這個和這個作品 –

+0

仍然出現相同 –

0
<li class="dropdown <?php if($active_mn=='view_class'|| $active_mn=='view_rooms') echo "open active";?>"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-bed"></i> Room Management <b class="fa fa-plus dropdown-plus"></b> </a> 
     <ul class="dropdown-menu"> 
      <li class="<?php if($active_mn=='add_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_class"> <i class="fa fa-caret-right"></i>Add Class</a> </li> 
      <li class="<?php if($active_mn=='view_class') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_class"> <i class="fa fa-caret-right"></i>View Class</a> </li> 
      <li class="<?php if($active_mn=='add_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/add_rooms"> <i class="fa fa-caret-right"></i>Add Rooms</a> </li> 
      <li class="<?php if($active_mn=='view_rooms') echo "active";?>"> <a href="<?php echo base_url()?>admin/view_rooms"> <i class="fa fa-caret-right"></i>View Rooms</a> </li> 
     </ul> 
     </li> 
相關問題