I am trying to pass a model to a bootstrap modal editor. I call the modal from an Ajax method. I can get the model from the controller, and view its properties from the script's success event. However, I cannot send this model "mod" to my bootstrap modal body. mod is always null when I call my partial view inside in my modal body. Is it possible to open/show a Bootstrap modal with a value passed to the modal-body.
@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');
}
});