0
大家好我開發在CakePHP中的應用,並已定義的元素menu_top.ctp如下:的CSS菜單項選擇問題的jQuery/CakePHP的
<script type="text/javascript">var path =location.pathname;
`
$(document).ready(function() {
alert(path);
/* select the menu nav tab based on the url */
$("#menu li a[href='" + [ path ] + "']").parents("li").each(function() {
$(this).addClass("current-menu-item");
});
});
</script>
<div id="welcomeMsg">
<?php
if($session->check('Auth.User')):
echo "<span style='float:right;color:#ffffff;'> Welcome ".$session->read('Auth.User.username')."</span>";
endif
?>
</div>
<div style="clear:both;"></div>
<div id="topNav">
<?php
if($session->check('Auth.User')): ?>
<ul id="menu" style="margin-top:10px;">
<li>
<?php echo $this->Html->link('Home',array('controller' => 'pages', 'action' => 'display', 'home')); ?>
</li>
<?php if($session->read('Auth.User.admin') == 1): ?>
<li class="">
<?php echo $this->Html->link('Admin',array('controller' => 'admin','action'=>'index')); ?>
</li>
<?php endif ?>
<li class="">
<?php echo $this->Html->link('Terms & Conditions/Privacy Policy',array('controller' => 'toc','action'=>'index')); ?>
</li>
<li class="">
<?php echo $this->Html->link('Contact Us',array('controller' => 'contact','action'=>'index')); ?>
</li>
<li class="">
<?php echo $this->Html->link('About Us',array('controller' => 'about','action'=>'index')); ?>
</li>
<li class="">
<?php echo $this->Html->link('Log Out',array('controller' => 'users','action'=>'logout')); ?>
</li>
</ul>
jQuery代碼定義上面選擇菜單項時,頂級網址在瀏覽器中打開例如。 http://localhost/mysite/admin
將選擇管理員選項卡,但是當我打開http://localhost/mysite/admin/users
時,選擇將丟失。 請幫我解決這個問題。 謝謝。
它並沒有奏效。我改變了代碼,但結果相同。 – deep 2011-04-27 02:33:40