我想刷新部分菜单,具体取决于用户通过Ajax选择。Ajax刷新部分视图
我有一个认证的布局,有这...
<div class="container-fluid body-content">
<div class="row">
<div class="col-lg-offset-2 col-md-offset-2 col-sm-offset-2 col-lg-10 col-md-10 col-sm-10 col-xs-10">
<div id="bodyContent" class="pad-top">
@RenderBody()
</div>
</div>
<div id="menu" style="display: inline; visibility: hidden">
@{ Html.RenderAction("GetMenuPartial", "Menu", noArea); }
</div>
</div>
然后那里面是的RenderAction我的控制器,它可以使根据用户角色的几个不同的菜单。
public PartialViewResult GetMenuPartial()
{
if (User.IsInRole(Roles.ApplicationCenter.Administrator))
{
return !string.IsNullOrEmpty(SessionHelper.GetImpersonationName()) ? GetApplyPartial() : PartialView("_MenuAdminPartial", GetUrl());
}
if (User.IsInRole(Roles.ApplicationCenter.Customer))
{
return PartialView("_MenuCustomerPartial", GetMenuCustomerViewModel());
}
return SessionHelper.GetApplicationId() == 0 ? PartialView("_MenuCandidatePartial", GetMenuCandidateViewModel()) : GetApplyPartial();
}
我的GET请求来刷新部分看起来像这样...
$.get('@Url.Action("GetMenuPartial", "Menu", new {area = ""})', {})
.done(function(menuCustomerViewModel) {
$("#menu").html(menuCustomerViewModel);
});
我能够刷新部分的部分,但是,这样做食堂的布局。我假设它不再加载该部分视图所在的div elemenet上的CSS。有人能指出我如何更好地处理这个问题的正确方向吗?
是的,你说得对。我没有注意到一个正在做菜单的JS功能。谢谢! – Hao
@霍恩现在工作了吗? – mahlatse