如何在不重新加载整个页面的情况下关闭弹出窗口

时间:2013-06-22 10:08:54

标签: jquery asp.net-mvc-3

单击删除时使用页面将打开弹出窗口并要求确认,现在我想在点击取消时关闭弹出窗口,但不要重定向到主页面。下面的代码是mvc中的删除视图...

@using (Html.BeginForm()) {
<p>
    <input type="submit" value="OK" /> 
   @Html.ActionLink("Back to List", "Index")

jquery代码是

$(".deleteimage").click(function (e) {
        var url = $(this).parent().attr('href');
        $("#dialog-delete").dialog({
            resizable: false,
            height: 180,
            width: 300,
            show: { effect: 'drop', direction: "up" },
            modal: true,
            draggable: false,
            open: function (event, ui) {
                $(this).load(url);
            },
            close: function (event, ui) {
                $(this).dialog('close');
            }
        });
        $("#dialog-delete").dialog('open');

        return false;
    });

在索引视图中使用此代码..

  @(new HtmlString(@Ajax.ImageActionLink("../../Content/images/grid/Del.png", "Delete", "Delete", "Delete", new { id = item.TerminalID }, "deleteimage", new AjaxOptions
         {
             HttpMethod = "GET",
             InsertionMode = InsertionMode.Replace,
             UpdateTargetId = "targetdiv"
       }))) 

1 个答案:

答案 0 :(得分:1)

为了关闭jQuery UI对话框,您可以使用close方法:

$("#dialog-delete").dialog('close');