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
}
});
});
如何使用Bootbox對話框而不是JavaScript對話框?將標準Javascript確認對話框轉換爲Bootbox確認
編輯
嗯,我已經試過,但沒有任何反應後點擊OK按鈕bootbox對話框
$(document).on("click", "#close", function (e) {
e.preventDefault();
var link = $(this).attr("href"); // "get" the intended link in a var
bootbox.confirm("Are you sure you want to close this Incident? This operation cannot be reversed.", function (result) {
if (result) {
document.location.href = link;
} else {
console.log("user declined");
}
});
});
請參閱編輯 – ASPCoder1450
我的JS調試器中出現一個錯誤,那就是:event.returnValue已棄用。請改用標準的event.preventDefault()。即使即時通訊已經使用preventDefault:s – ASPCoder1450
這不是一個錯誤。它不是由你的代碼造成的。 –