Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close sweetalert #58

Closed
neelbhanushali opened this issue Jun 8, 2019 · 12 comments
Closed

Close sweetalert #58

neelbhanushali opened this issue Jun 8, 2019 · 12 comments

Comments

@neelbhanushali
Copy link

How do you close a sweetalert using js?

@Grandizer
Copy link

Yes, I want to know this as well. I upgraded from 1.5 to 2.0.5 and now close does not work.

We initially had:


this.$swal({
  title: '<i class="far fa-spin fa-spinner"></i>',
  text: text,
  showCancelButton: false,
  showConfirmButton: false,
  showCloseButton: false,
  allowOutsideClick: false,
  allowEscapeKey: false,
  allowEnterKey: false,
});

And then once the save was finished we would call:

this.$swal.close();

Since the update, now I get the error:

Uncaught (in promise) TypeError: this.$swal.close is not a function

@Grandizer Grandizer mentioned this issue Jun 25, 2019
@avil13
Copy link
Owner

avil13 commented Jun 26, 2019

This is because sweetalert2 v.8 changed their API.
To solve this problem, I did not find the time.
I apologize for that.

@Grandizer
Copy link

Understood. I get we are all busy and I thank you for your time to get us this far. Do you have a guestimate of when you will be able to get the time?

@avil13 avil13 closed this as completed in 34267e8 Jun 26, 2019
@neelbhanushali
Copy link
Author

Please don't close the issue. Let it be open.

It will keep you posted that this is a good feature to be included in the plugin.

@avil13 avil13 reopened this Jun 27, 2019
@Grandizer
Copy link

@neelbhanushali - I installed the 2.1.0 (the latest) and it works as it should again with the following code to use javascript to close a popup.

this.$swal.close();

@neelbhanushali
Copy link
Author

I shall update the plugin. Thanks @Grandizer @avil13

@neelbhanushali
Copy link
Author

I checked after updating the plugin. It works.

@avil13 you can close this issue. :)

@avil13 avil13 closed this as completed Jun 28, 2019
@avil13
Copy link
Owner

avil13 commented Jun 28, 2019

Thank you all

@jonalxh
Copy link

jonalxh commented Jul 10, 2020

Not working for me on 3.0.6 version, it throws the same error and doesn't let me close it programmatically.

@Gujionsen
Copy link

@jonalxh Same here, Did you find solution?

@jonalxh
Copy link

jonalxh commented Jul 13, 2020

@elguja No, I've just downgraded it to 3.0.3.

@mhmdunl1
Copy link

mhmdunl1 commented Jul 5, 2023

You should import like this first

import Swal from 'sweetalert2'

Then you can close sweetalert in js like this.

Swal.close();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants