0

こんにちは、確認ダイアログ (ブートボックス) を機能させようとしています。確認ダイアログが表示されますが、[OK] ボタンを押しても何もしません。

 $(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>

問題は、OKボタンを機能させるにはどうすればよいですか?

編集: ボタンの 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      
                }
            });
        });
4

1 に答える 1

0

あなたのコメントに基づいて

$(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      
     }
  });
});
于 2014-03-06T19:58:07.930 に答える