@ Ajax.ActionLink中的jQuery对话框(AjaxOptions)

时间:2015-04-13 21:59:55

标签: c# jquery ajax asp.net-mvc

我正试图在OnBegin方法中的@ Ajax.ActionLink(AjaxOptions)中打开JQuery对话框。我可以打开对话框,但确认什么都没发生?

一旦我确认我想在控制器中控制goto DeleteEmail方法。

我不知道我在这里失踪了什么。

  @Ajax.ActionLink(
             "Delete",
            "DeleteEmail",
            new { CommunicationLocation = commemail.CommunicationLocation,  CommunicationType = "email" },
            new AjaxOptions()
            {
               HttpMethod = "Post",
               UpdateTargetId = "DivEmailContainer",
               OnBegin = "return ConfirmDone()"
            },
            new { @class = "btn btn-success" })

DIV

<div id="dialog-confirm" title="Delete the item?">
        <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This item will be deleted. Are you sure?</p>
    </div>

JS

<script type="text/javascript">
      $(document).ready(function () {
            $("#dialog-confirm").dialog({
                autoOpen: false,
                modal: true,
                resizable: false,
                height: 180,
            });
      });

  function ConfirmDone() {
            var returnVal = false;
        $("#dialog-confirm").dialog({
            buttons: {
                "Confirm": function () {
                    returnVal = true;
                    $(this).dialog('close');
                },
                "Cancel": function () {
                    returnVal = false;
                    $(this).dialog("close");
                }
            }
        });
        $("#dialog-confirm").dialog("open");
        return returnVal;
    };

0 个答案:

没有答案