[英]Partial View not being rendered in Tab navigation
我正在嘗試創建一個基於選項卡的導航,但是不同按鈕的局部視圖不呈現,而只是第一個。
這是我的標簽視圖:
@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視圖
這應該為每個不同的標簽顯示不同的局部視圖。
第一個選項卡總是正確顯示和呈現,但后面的兩個則不然。
我已經解決了這個問題。
在選項卡的第一個按鈕的視圖中,我忘了關閉一個按鈕,它也包裹了其他選項卡的容器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.