简体   繁体   English

无法关闭模式弹出窗口

[英]Unable to close modal popup

I have View opening in popup as shown below. 我在弹出窗口中打开视图,如下所示。

 $(function () {
        $('#lnkPremiumAllocationPlan').click(function () {
            var selPolicyId = $('#sltPolicyName option:selected').val();
            $.ajax({              

                url: '@Url.Action("GetPolicyPremiumAllocation", "Policy")',

                data: { policyID: selPolicyId },

                type: 'POST',
                success: function (data) {
                    if (data.length >0) {                       

                        $("#modal_dialog").load(data);
                        $("#modal_dialog").dialog("open");
                    }                 
            }

            });
        });

        $("#modal_dialog").dialog({
            autoOpen: false,
            height: 600, width: 'auto',
            title: "Premium Allocation",
            buttons: {
                Cancel: function () {                   
                    $(this).dialog("close");                 

                }
            },
            modal: true
        });
    })
</script>

When I click on the Cancel button of the popup window, it does not close. 当我单击弹出窗口的“取消”按钮时,它不会关闭。

I have included the following files as well. 我也包括以下文件。

<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery-ui-1.8.20.min.js"></script>
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />

Unable to figure out what I am doing wrong. 无法弄清楚我在做什么错。 Please, help. 请帮忙。

use $("#modal_dialog") instead of $(this). 使用$(“#modal_dialog”)代替$(this)。 this refers the current object only . 这仅指当前对象。

$("#modal_dialog").dialog({
   autoOpen: false,
    height: 600, width: 'auto',
    title: "Premium Allocation",
    buttons: {
        Cancel: function () {                   
            $("#modal_dialog").dialog("close"); 
        }
    },
    modal: true
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM