我正在尝试创建一个基于选项卡的导航,但是不同按钮的局部视图没有呈现,只是第一个。
这是我的标签页视图:
@model Franchise.Web.AMAdministrationModel
<nav class="tab-nav">
<ul>
<li class="tab tab1 @if (Model.SelectedTab == 1) { @Html.Raw("selected"); }" rel="1"><a>Contact Details</a></li>
<li class="tab tab2 @if (Model.SelectedTab == 2) { @Html.Raw("selected"); }" rel="2"><a>Agencies</a></li>
<li class="tab tab3 @if (Model.SelectedTab == 3) { @Html.Raw("selected"); }" rel="3"><a>Contract</a></li>
</ul>
</nav>
<div class="spacer_0"></div>
<script>
$(document).ready(function () {
@Model.jsToLoad
$('.tab').click(function () {
updateTab($(this).attr('rel'));
});
});
function updateTab(tab) {
$('.tab').removeClass('selected');
$('.tab-content').removeClass('show');
$('.tab' + tab).addClass('selected');
$('.tab-content' + tab).addClass('show');
if(tab>=2){
$.ajax({
url: '@Url.Action("detailstab")',
type: 'Get',
data: { id: @Model.AgentID, tab: tab },
success: function (response) {
$('.tab-content'+tab).empty();
$('.tab-content' + tab).html(response);
if (tab == 3) {
$(".dz-form").dropzone({
url: "@Url.Action("upload")",
queuecomplete: function (file, response) {
showAlert('alert', 'success', 'Contract', 'Upload complete.');
setTimeout(function () {
window.location.href = '@Url.Action("edit/" + @Model.AgentID + "/photos")';
}, 1000);
}
});
}
}
});
}
}
</script>
When you click a tab it should redirect the code to the detailstab (and it does)
[HttpGet]
public ActionResult DetailsTab(int id, int tab)
{
AMAdministrationModel ama = new AMAdministrationModel();
// to do claudio
var agent = _amadministration.GetHeadAgentDetails(id, UserSession.GetRegion());
if (agent == null || agent[0].AgentID == 0)
{
ExLog.HandleException(new NullReferenceException("Head Agent " + id + " not found, please use the site navigation to find your way around!"));
}
else
{
if(tab == 2)
{
return new EmptyResult();
//return partial view in the 3rd deplyment
}
else if (tab == 3)
{
ama.AgentID = id;
ama.ContractStartDate = agent[0].JoinDate;
ama.ContractEndDate = agent[0].LeaveDate;
ama.UserPermission = _userpermission;
return PartialView("ContractPartial", ama);
}
}
return new EmptyResult();
}
但是未渲染ContractPartial视图
这应该为每个不同的标签显示不同的局部视图。
第一个选项卡总是正确显示和呈现,但后面的两个则不能。
答案 0 :(得分:0)
我已经解决了问题。
在该标签的第一个按钮的视图中,我忘了关闭一个按钮,它也包裹了其他标签的容器。