如何使_Layout每次都不渲染? [英] How to make the _Layout not render every time?
问题描述
我创建了一个MVC3的测试项目,该项目只有一个剃刀布局.
在布局中,我使用一个jquery来创建动态菜单,我只想获得效果是当我单击这些菜单时,它应该在主体段中返回不同的局部视图,并且布局菜单应该记住我在布局上单击时的菜单状态页面.
但是结果是,当我每次单击菜单时,布局将再次呈现,并且菜单状态将恢复,如何解决该问题?
这是我的代码!有人可以帮我吗?谢谢!!!
I created a test project of MVC3,and the project has only one layout of razor.
In the Layout I use a jquery to create dynamic menus,I just want get the effect is when i clicked these menu ,it should return different partial views in the body segment,and the layout menu should remember the menu state i clicked on the layout page.
But the result is ,when i click the menus everytime ,the layout will render again,and the menu state will restore ,how to resolve the problem?
This is my code !!! Can anybody help me?Thanks!!!
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$(".sidebar1 dl dd").hide();
$(".sidebar1 dl dt").click(function () {
$(".sidebar1 dl dd").not($(this).next()).hide();
$(this).next().slideToggle(500);
});
});
</script>
</head>
<body>
<div class="container">
<div class="header"><a href="#"><img src="/Content/images/logo.png" alt="logo" name="Insert_logo" width="180" height="90" id="Insert_logo" style="background-color: #C6D580; display:block;" /></a>
<!-- end .header --></div>
<div class="sidebar1">
<dl class="nav">
<dt><a href="#">aaaaa</a></dt>
<dd>
<ul>
<li><a href="#">AAAA</a></li>
<li><a href="#">BBBB</a></li>
<li><a href="#">CCCC</a></li>
</ul>
</dd>
<dt><a href="#">aaaaa</a></dt>
<dd>
<ul>
<li><a href="#">AAAA</a></li>
<li><a href="#">BBBB</a></li>
<li><a href="#">CCCC</a></li>
</ul>
</dd>
</dl>
</div>
<div class="content">
@RenderBody()
</div>
</body>
</html>
推荐答案
(function(){
(function () {
(.sidebar1 dl dd").hide();
(".sidebar1 dl dd").hide();
(.sidebar1 dl dt").click(function(){
(".sidebar1 dl dt").click(function () {
这篇关于如何使_Layout每次都不渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!