引导框javascript确认删除

引导框javascript确认删除,javascript,confirm,bootbox,Javascript,Confirm,Bootbox,我正在使用asp.NETMVC5 在 如何删除HTML操作链接? 请查看代码的完整详细信息:- Javascript代码:- <script src="~/Scripts/bootbox.min.js"></script> $(document).on("click", ".MyLink", function (e) { var self = this; bootbox.confirm("Are you sure?", funct

我正在使用asp.NETMVC5

如何删除
HTML操作链接
? 请查看代码的完整详细信息:-

Javascript代码:-

<script src="~/Scripts/bootbox.min.js"></script>

    $(document).on("click", ".MyLink", function (e) {
        var self = this;
        bootbox.confirm("Are you sure?", function (result) {
            Example.show("Confirm result: " + result);
            $(self).remove();
        });
    });

$('.MyLink').remove()
在回调中?@adeneo:在
回调中
是指在Javascript代码或其他地方?替换
示例。用上面的行显示
?@adeneo:我单击链接时,它只是删除了记录,没有确认对话框。我还需要确认对话框,你是这样做的吗
<script src="~/Scripts/bootbox.min.js"></script>

    $(document).on("click", ".MyLink", function (e) {
        var self = this;
        bootbox.confirm("Are you sure?", function (result) {
            Example.show("Confirm result: " + result);
            $(self).remove();
        });
    });
<h2>Index</h2>

  <p>Content here. <a class="MyLink" href=#>Alert!</a></p>
    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
<table class="table">
        <tr>
            <th> First Name </th>
            <th> Last Name </th>
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td> @Html.DisplayFor(modelItem => item.FirstName) </td>
            <td> @Html.DisplayFor(modelItem => item.LastName) </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id=item.CustomerID }) |
                @Html.ActionLink("Details", "Details", new { id = item.CustomerID }) |
                @*@Html.ActionLink("Delete", "Delete", new { id = item.CustomerID, @class = "MyLink" })*@
                <a href="@Url.Action("Delete", new { id = item.CustomerID })" class="MyLink">Delete</a>
            </td>
        </tr>
    }
public ActionResult Delete(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Customer customer = db.Customers.Find(id);
        db.Customers.Remove(customer);
        db.SaveChanges();
        if (customer == null)
        {
            return HttpNotFound();
        }
        return RedirectToAction("Index");
        //return View(customer);
    }