Remove the OK button from the welcome warning dialog box

I am using the JavaScript sweetalert2 library .

I want to remove the OK button from the warning window, but I did not find any property to prevent this button from being displayed.

I use the timer property timer:1000to close the alert in one second. Therefore, I do not think that the OK button is used in this question.

enter image description here

+17
source share
9 answers

You can use the following properties:

showCancelButton: false, // There won't be any cancel button
showConfirmButton: false // There won't be any confirm button

Like this

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')
    }
  }
)
+31
source

Update 6/4/2018

showCancelButton showConfirmButton . : true, , : false, . .

,

showCancelButton: false;

showConfirmButton: false;

buttons: false;

+13

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

+4

: $(".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'); 

        });
}
+3
swal({

    title: "Success",
    text: "Permissions assigned Successfully",
    icon: "success",
    closeOnClickOutside: false,
})

closeOnClickOutside: false, .

+2

showConfirmButton false.

0

buttons: false;

swal({
    title: 'Auto close alert!',
    text: 'I will close in 2 seconds.',
    timer: 2000,
    showCancelButton: false,
    showConfirmButton: false
});
0

.

Swal.fire({
  type: 'error',
  title: 'Cancelled',
  text: 'Your offer is safe 🙂',
  showConfirmButton: false,
  timer: 2000
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
Hide result

0

Before adding any buttons, clear all the buttons, and then add them again (provided that the name of the notification is "A") -

A.getButtonTypes().clear();
ButtonType OpenStorage=new ButtonType("Open Storage");
A.getButtonTypes().addAll(OpenStorage,ButtonType.CANCEL,ButtonType.NEXT);

Hope this helps !!!

-one
source

Source: https://habr.com/ru/post/1015203/


All Articles