Prevent auto close sweet alert

See original GitHub issue

Trying to do simple stuff. I do not want to close popup until user click on confirm button (I turned off this option but popup is still closing). Here is my code:

sweetAlert({
    title: "Hello",
    text: "<button type='button' class='btn btn-fb fb-share'>Share on Facebook</button>",
    type: null,
    confirmButtonText: "Close",
    html: true,
    closeOnConfirm: false, //It does close the popup when I click on close button
    closeOnCancel: false,
    allowOutsideClick: false
});

$(document).on( "click",".fb-share",  function(e){
    //here sweet alert closes when I press this button. 
    openFbPopup(); 
});

How do I prevent closing sweet alert?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:8

github_iconTop GitHub Comments

19reactions
mushtaqjcommented, Jan 13, 2018

I know this is late, but might help somebody in the future

@moazam1 The option has been changed to

swal({
  closeOnClickOutside: false,
});

https://sweetalert.js.org/docs/#closeonclickoutside

1reaction
soypaduanocommented, May 18, 2018

This didn’t worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent SweetAlert to be closed on clicking outside the popup ...
If you are using Sweet Alert 2, you can use this configuration allowOutsideClick: false. This should work.
Read more >
sweet alert prevent close Code Example - Code Grepper
how to stop user from clicking outside sweetalert 2. whatever by Outstanding Osprey on ... Answers related to “sweet alert prevent close”.
Read more >
Timer Methods - SweetAlert2 example
let timerInterval Swal.fire({ title: 'Auto close alert!', html: 'I will close in <strong></strong> seconds.<br/><br/>' + '<button id="increase" class="btn ...
Read more >
Sweet Alert worked, but it closes within seconds why?
Alert ::success('Data Deleted successfully')->autoClose(5000);. Or use the persistent() method if the user should close the alert: Copy Code
Read more >
Docs - SweetAlert
Closes the currently open SweetAlert, as if you pressed the cancel button. swal.close(). getState, Get the state of the current SweetAlert modal. swal.getState ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found