如何制作一个简单的导航器 - 内容菜单
How to make a simple navigator - content menu
附件是我的导航器的代码片段
<!-- Navigator -->
<div style="position:abolute;top:50px" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul id="yw0" class="nav">
<li class="active"><a href="<?php $this->renderPartial("company",false); ?>" style="color:black">Company</a></li>
<li><a style="color:black" href="#"><i class="fa fa-lightbulb-o"></i> FAQs</a></li>
<li><a style="color:black" href="#"><i class="fa fa-question-circle"></i> Help Center</a></li>
<li><a style="color:black" href="#"><i class="fa fa-newspaper-o"></i> Press</a></li>
<li><a style="color:black" href="#">Careers</a></li>
<li><a style="color:black" href="#"><i class="fa fa-envelope-o"></i> Contact Us</a></li>
</ul>
</div>
</div>
</div>
<!-- Content -->
我实际上是在尝试建立一个逻辑,即每当我单击 link 时,它应该渲染相应的文件并突出显示导航器下方的菜单。我尝试执行以下操作
<a href="<?php $this->renderPartial("company",false); ?>"
但我想这不是正确的方法..不知道我该如何实现?
这将进入您的视图文件
<!-- Navigator -->
<div style="position:abolute;top:50px" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul id="yw0" class="nav">
<li class="active"><a href="#" onclick="showData('company')" style="color:black">Company</a></li>
<li><a onclick="showData('user')" style="color:black" href="#"><i class="fa fa-lightbulb-o"></i> FAQs</a></li>
<li><a style="color:black" href="#"><i class="fa fa-question-circle"></i> Help Center</a></li>
<li><a style="color:black" href="#"><i class="fa fa-newspaper-o"></i> Press</a></li>
<li><a style="color:black" href="#">Careers</a></li>
<li><a style="color:black" href="#"><i class="fa fa-envelope-o"></i> Contact Us</a></li>
</ul>
</div>
</div>
</div>
<div class="main-content">
<div id="company" class="renderContent">
<?php $this->renderPartial("company",false); ?>
</div>
<div id="user" class="renderContent">
<?php $this->renderPartial("user",false); ?>
</div>
<!--- for every menu item there should be a view rendered here--->
</div>
<!-- Content -->
这将进入您的 js
function showData(id) {
$('.renderContent').hide();
$('.nav li').removeClass('active');
$(this).addClass('active');
$('#'+id).show();
}
$('.renderContent').hide();
附件是我的导航器的代码片段
<!-- Navigator -->
<div style="position:abolute;top:50px" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul id="yw0" class="nav">
<li class="active"><a href="<?php $this->renderPartial("company",false); ?>" style="color:black">Company</a></li>
<li><a style="color:black" href="#"><i class="fa fa-lightbulb-o"></i> FAQs</a></li>
<li><a style="color:black" href="#"><i class="fa fa-question-circle"></i> Help Center</a></li>
<li><a style="color:black" href="#"><i class="fa fa-newspaper-o"></i> Press</a></li>
<li><a style="color:black" href="#">Careers</a></li>
<li><a style="color:black" href="#"><i class="fa fa-envelope-o"></i> Contact Us</a></li>
</ul>
</div>
</div>
</div>
<!-- Content -->
我实际上是在尝试建立一个逻辑,即每当我单击 link 时,它应该渲染相应的文件并突出显示导航器下方的菜单。我尝试执行以下操作
<a href="<?php $this->renderPartial("company",false); ?>"
但我想这不是正确的方法..不知道我该如何实现?
这将进入您的视图文件
<!-- Navigator -->
<div style="position:abolute;top:50px" class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<ul id="yw0" class="nav">
<li class="active"><a href="#" onclick="showData('company')" style="color:black">Company</a></li>
<li><a onclick="showData('user')" style="color:black" href="#"><i class="fa fa-lightbulb-o"></i> FAQs</a></li>
<li><a style="color:black" href="#"><i class="fa fa-question-circle"></i> Help Center</a></li>
<li><a style="color:black" href="#"><i class="fa fa-newspaper-o"></i> Press</a></li>
<li><a style="color:black" href="#">Careers</a></li>
<li><a style="color:black" href="#"><i class="fa fa-envelope-o"></i> Contact Us</a></li>
</ul>
</div>
</div>
</div>
<div class="main-content">
<div id="company" class="renderContent">
<?php $this->renderPartial("company",false); ?>
</div>
<div id="user" class="renderContent">
<?php $this->renderPartial("user",false); ?>
</div>
<!--- for every menu item there should be a view rendered here--->
</div>
<!-- Content -->
这将进入您的 js
function showData(id) {
$('.renderContent').hide();
$('.nav li').removeClass('active');
$(this).addClass('active');
$('#'+id).show();
}
$('.renderContent').hide();