我使用的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