我有一个大问题。我尝试了更多方法,但我无法实现解决方案,我不知道为什么?!
我有一个MVC Web应用程序,我必须创建9个视图来创建我的一个模型。我为create创建了一个视图,在创建视图中我使用了 div
,并且在每个 div
中,我想渲染其中一个局部视图和在这9个局部视图的每个视图中,我使用了2或3个局部视图:这意味着,我使用了嵌套的局部视图。但是当我通过这段代码完成这项工作时,任何部分视图的java脚本代码都不起作用,我不知道为什么以及如何在事先处理它。
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>