我正在尝试将模型传递给引导模式编辑器。我从Ajax方法调用模式。我可以从控制器中获取模型,并从脚本的成功事件中查看其属性。但是,我无法将此模型“ mod”发送到我的引导模态主体。当我在模态主体中调用局部视图时,mod始终为null。是否可以通过将值传递给模态主体来打开/显示Bootstrap模态。
@model StockItemViewModel
@{
ViewData["Title"] = "ProductServiceIndex";
StockItemViewModel mod = Model;
<div class="modal fade" id="prodserviceModal" tabindex="-1" role="dialog" aria-labelledby="myModal-label">
<div class="modal-dialog vertical-align-center">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModal-label">Product/Service Information</h4>
<h4>@mod.StockItemName</h4>
</div>
<div class="modal-body" id="productServicePlaceholder">
@await Html.PartialAsync("_ProductServiceModal", mod)
</div>
</div>
</div>
function ajax_get(data) {
$.ajax({
url: "/Purchasing/AddEditProdServ",
type: "GET",
data: data,
success: function (data) {
//$('#productServicePlaceholder').html(data);
mod = data;
//alert(mod.StockItemId);
$('#prodserviceModal').modal('show');
}
});