MVC Partialview详细操作未呈现到jquery模式对话框中?

时间:2016-04-06 23:15:46

标签: javascript jquery html ajax asp.net-mvc

在单击部分视图详细信息按钮时,我想将动作结果显示到jquery模式对话框,但它没有发生,而是结果显示在下一页中。我尝试了以下方式。 请参阅随附的屏幕截图。感谢您的帮助。

页面加载了jquery-1.10.2.min.js,jquery-ui-1.11.4.js和jquery.unobtrusive-ajax.js

  1. 在Main.cshtml中定义
  2. 在Ajaxcall上加载页面时,使用html结果呈现Detailview1。
  3. 如果单击详细信息按钮,则将partialview加载到另一个不在模式对话框中的页面。
  4. 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>
    }

    enter image description here

0 个答案:

没有答案
相关问题