在单击部分视图详细信息按钮时,我想将动作结果显示到jquery模式对话框,但它没有发生,而是结果显示在下一页中。我尝试了以下方式。 请参阅随附的屏幕截图。感谢您的帮助。
页面加载了jquery-1.10.2.min.js,jquery-ui-1.11.4.js和jquery.unobtrusive-ajax.js
function loadpartialview(pageurl) {
//alert('loadpartialview ');
$.ajax({
type: "GET",
//url: pageurl,
url: '@Url.Action("GetPVAjaxCall", "VADV")',
contentType: "application/json; charset=utf-8",
dataType: "html",
success: function (result) {
//alert(result);
$("#DetailView1").empty();
$("#DetailView1").html(result);
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Error in ajax call VADV.loadpartialview:' + textStatus + ' - ' + errorThrown);
}
});
}
$(document).on('click', '.openDialog1', function () {
alert('openDialog1 ' + this.href + ' ' + $(this).attr("data-dialog-id"));
e.preventDefault();
$("<div></div>")
.addClass("dialog")
.attr("id", $(this).attr("data-dialog-id"))
.appendTo("body")
.dialog({
height: 500,
width: 1000,
title: $(this).attr("data-dialog-title"),
close: function () { $(this).remove() },
modal: true
})
.load(this.href);
});
$(function () {
var url = "/VADV/GetPVAjaxCall";
loadpartialview(url);
});
<script src="~/Scripts/jquery-ui-1.11.4.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<link href="~/Content/themes/base/all.css" rel="stylesheet" />
<link href="~/css/bootstrap-datepicker3.css" rel="stylesheet" />
<div id="DetailView1"></div>
Partialview (GetPVAjaxCall.cshtml)
@model IEnumerable<VAMDEScheduler.Models.VADetailRecord>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.VeteranName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ClaimType)
</td>
<td>
@Html.DisplayFor(modelItem => item.DoctorName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ClaimFileDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.ActionLink("Details", "Details", "VADV", new { id = item.Id },
new { @class = "openDialog1", data_dialog_id = "result1", data_dialog_title = "Modal Title" })
</td>
</tr>
}