【问题标题】:Bootbox ASP.NET MVC ConfirmationsBootbox ASP.NET MVC 确认
【发布时间】:2014-03-06 19:21:44
【问题描述】:

您好,我正在尝试让确认对话框 (Bootbox) 工作。它显示确认对话框,但在按下确定按钮时不执行任何操作。

 $(document).on("click", "#close", function (e) {
            e.preventDefault();
            var $this = $(this);
            bootbox.confirm("Are you sure you want to close this Service Request? This operation cannot be reversed."
                , function (result) {
                    if (result) {
                        $this.closest('form').submit();
                    } else {
                        console.log("user declined");
                    }
                });
        });

我认为这是错误的:

$this.closest('form').submit();

我的按钮是<td><a href="@Url.Action("CloseLog", "Log", new {id = item.LogID})"><span class="glyphicon glyphicon-trash" id="close"></span></a>

问题是如何让确定按钮工作?

编辑: 我可以从按钮中的 onClick 调用此函数吗?如果有怎么办?

$(document).on("click", ".alert", function (e) {
            var link = $(this).attr("href"); // "get" the intended link in a var
            e.preventDefault();
            bootbox.confirm("Are you sure?", function (result) {
                if (result) {
                    document.location.href = link;  // if result, "set" the document location      
                }
            });
        });

【问题讨论】:

  • 你的意思是按ok后什么都没有发生吗?
  • 完全正确。什么都没有发生
  • $ 是一个元符号,不要将它用作变量名的一部分,试试 $(this).closest('form').submit();
  • 请看我的问题编辑@VladL
  • 或者我将如何使用它?

标签: javascript jquery asp.net asp.net-mvc bootbox


【解决方案1】:

根据您的评论

$(document).ready(function()
{
  $("#close").click(function()
  {
     var link = $(this).attr("href"); // "get" the intended link in a var
     var result = confirm("Are you sure?");
     if(result)
     {
       document.location.href = link;  // if result, "set" the document location      
     }
  });
});

【讨论】:

  • 抱歉没用。它根本不显示任何对话框,只是继续删除
  • 我需要以任何方式更改我的按钮/链接吗?
  • @ASPCoder1450 和现在?
  • 现在它只显示一个标准的 javascript 确认对话框而不是引导框
  • @ASPCoder1450 好吧,我真的不知道你有什么以及你想要实现什么。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-26
  • 2012-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多