我使用的JavaScript甜警報庫:刪除「OK」甜警告對話框按鈕
https://limonte.github.io/sweetalert2/
https://github.com/limonte/sweetalert2
我想從警告框去除OK按鈕,但我沒有找到任何不顯示此按鈕的屬性。
我使用計時器屬性timer:1000
在一秒鐘內關閉警報。 所以,我不認爲在這個問題上有一個OK按鈕的用法。
我使用的JavaScript甜警報庫:刪除「OK」甜警告對話框按鈕
https://limonte.github.io/sweetalert2/
https://github.com/limonte/sweetalert2
我想從警告框去除OK按鈕,但我沒有找到任何不顯示此按鈕的屬性。
我使用計時器屬性timer:1000
在一秒鐘內關閉警報。 所以,我不認爲在這個問題上有一個OK按鈕的用法。
您可以使用這些屬性:
showCancelButton: false, // There won't be any cancel button
showConfirmButton: false // There won't be any confirm button
喜歡這個
swal({
title: 'Auto close alert!',
text: 'I will close in 2 seconds.',
timer: 2000,
showCancelButton: false,
showConfirmButton: false
}).then(
function() {},
// handling the promise rejection
function (dismiss) {
if (dismiss === 'timer') {
//console.log('I was closed by the timer')
}
}
)
使用我的應用程序:angular2 + sweetalert2,節省了我的時間! :) – amey
嘗試showConfirmButton
屬性設置爲false。
你需要設置showConfirmButton:false
在您的配置。
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showConfirmButton:false,
confirmButtonText: 'Yes, delete it!'
})
這裏的fiddle
添加任何按鈕,清除所有的按鈕,然後在重新加入他們像(假設警報名稱是「A」) -
A.getButtonTypes().clear();
ButtonType OpenStorage=new ButtonType("Open Storage");
A.getButtonTypes().addAll(OpenStorage,ButtonType.CANCEL,ButtonType.NEXT);
希望它會幫助!
這個工作對我來說:$(".confirm").attr('disabled', 'disabled');
我的功能:
function DeleteConfirm(c){
swal({
title: "Want to delete this item?",
text: "You will not be able to undo this action!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function(){
$(".confirm").attr('disabled', 'disabled');
});
}
集'showConfirmButton:FALSE'在你的配置。 [鏈接到文檔](https://limonte.github.io/sweetalert2/#allow-enter-key) – haxxxton