こんにちは、確認ダイアログ (ブートボックス) を機能させようとしています。確認ダイアログが表示されますが、[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
}
});
});