Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "OK" button from sweet alert dialog

I am using javascript sweetalert2 library.

I want to remove the OK button from the alert box but I did not find any property for not to display this button.

I am using the timer property timer:1000 for closing the alert in one second. So, I don't think there is a use of the ok button in this matter.

enter image description here

like image 448
Ankush Rishi Avatar asked Feb 23 '17 05:02

Ankush Rishi


People also ask

How do I change my sweet alert theme?

Or, if you want to quickly start a new theme, run npm run create-new-theme my-awesome-theme . This will automatically start the server after creating the theme's default files. If you interrupt the server and want to restart it, use npm run start -- --theme <theme-name> or yarn start --theme <theme-name>


1 Answers

You can use these 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')     }   } ) 
like image 91
Viplock Avatar answered Sep 21 '22 07:09

Viplock