我有一个大问题。我尝试了更多方法,但我无法实现解决方案,我不知道为什么?!
我有一个 MVC Web 应用程序,我必须创建 9 个视图来创建我的模型之一。我为创建创建了一个视图,在我使用的创建视图中div
,div
我想渲染其中一个局部视图,在这 9 个局部视图中的每一个中,我使用了 2 个或 3 个局部视图:这意味着,我使用了嵌套的局部视图. 但是当我通过这段代码完成这项工作时,任何部分视图的 java-script 代码都不起作用,我不知道为什么以及如何处理它,谢谢。
VIEW(create)..>partial-view(pvinputfaulty)...>partial-view(invoiceitemgrid)...> partial-view (partbookletpopup)
<div class="editor-label">
invoicetype:
</div>
<div class="radio">
@Html.RadioButtonForEnum(model => model.Invoice_.Invoice_Mode)
</div>
<div>
<div class="editor-label">
input type :
</div>
<div style="display: none" id="inputinvoicetype" class="radio">
@Html.RadioButtonForEnum(model => model.Invoice_.InputInvoice_Type)
</div>
<div style="display: none" id="outputinvoicetype" class="radio">
@Html.RadioButtonForEnum(model => model.Invoice_.OutInvoice_Type)
</div>
</div>
<div id="PartialViewContent">
<div id="divPV1"></div>
<div id="divPV2"></div>
<div id="divPV3"></div>
<div id="divPV4"></div>
<div id="divPV5"></div>
<div id="divPV6"></div>
<div id="divPV7"></div>
<div id="divPV8"></div>
<div id="divPV9"></div>
</div> </div>
}
$(document).ready(function () {
$("input[type=radio]").change(function () {
var invoicemode = $(this).val();
if (invoicemode == "Output") {
$('.mainContent #divPV1').empty();
$('.mainContent #divPV2').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV7').empty();
$('.mainContent #divPV8').empty();
$('.mainContent #divPV9').empty();
$("#inputinvoicetype").hide();
$("#outputinvoicetype").show();
}
});
})
$(document).ready(function () {
$("#inputinvoicetype input[type=radio]").change(function () {
var radio = $(this).val();
if (radio == "faulty") {
$('.mainContent #divPV2').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV1').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else if (radio == "overplus") {
$('.mainContent #divPV1').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV2').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else if (radio == "Reconstructed") {
$('.mainContent #divPV2').empty();
$('.mainContent #divPV1').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV3').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else if (radio == "Bought") {
$('.mainContent #divPV2').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV1').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV4').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else if (radio == "New_pieces") {
$('.mainContent #divPV2').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV1').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV5').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else {
$('.mainContent #divPV2').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV1').empty();
$('.mainContent #divPV6').load('@Url.Action("PVInputFaulty", "Invoice")');
}
})
})
$(document).ready(function () {
$("#outputinvoicetype input[type=radio]").change(function () {
var radio = $(this).val();
if (radio == "Installed_in_trains") {
$('.mainContent #divPV9').empty();
$('.mainContent #divPV8').empty();
$('.mainContent #divPV7').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else if (radio == "Useless") {
$('.mainContent #divPV9').empty();
$('.mainContent #divPV7').empty();
$('.mainContent #divPV8').load('@Url.Action("PVInputFaulty", "Invoice")');
}
else {
$('.mainContent #divPV7').empty();
$('.mainContent #divPV8').empty();
$('.mainContent #divPV9').load('@Url.Action("PVInputFaulty", "Invoice")');
}
})
})
$(document).ready(function () {
$("input[type=radio]").change(function () {
var invoicemode1 = $(this).val();
if (invoicemode1 == "Input") {
$('.mainContent #divPV1').empty();
$('.mainContent #divPV2').empty();
$('.mainContent #divPV3').empty();
$('.mainContent #divPV4').empty();
$('.mainContent #divPV5').empty();
$('.mainContent #divPV6').empty();
$('.mainContent #divPV7').empty();
$('.mainContent #divPV8').empty();
$('.mainContent #divPV9').empty();
$("#inputinvoicetype").show();
$("#outputinvoicetype").hide();
}
});
})
</script>