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

Multiple Sweet Alerts after eachother? #472

Closed
inctor opened this issue Nov 11, 2015 · 12 comments
Closed

Multiple Sweet Alerts after eachother? #472

inctor opened this issue Nov 11, 2015 · 12 comments

Comments

@inctor
Copy link

inctor commented Nov 11, 2015

Hey,

Thanks for the sweet plugin, really love it!
However i have a small challenge when i have to chain multiple "Confirms" after eachother.

If you click "too fast" on the "Confirm" button, the page just get's stuck, and get non-responsive, and the next few Confirms don't show.

I bypassed this slightly, by adding a delay to the SWAL call, but if you click faster than the delay, it'll break again.

A pen showing the case:
http://codepen.io/anon/pen/dYQapo

However the page seems to stay responsive, but the next SWAL is not shown, only shortly as the old one is fading out.

And this pen showing the case with a delay, that if you click confirm before the finishes loading the SWAL, it just stops showing the next one.
http://codepen.io/anon/pen/QjJYdm

Similar/same as #433, #359 & #253 .

I hope to hear from you! :)

@hcharley
Copy link

Unfortunately, I ran into this bug as well which pretty much rendered sweetalert unusable for my project's needs.

It's a shame as I don't have the time to start digging around the code to push my own fix, but I love the functionality of the library. I will be watching this to see if it gets fixed and the moment it does, you can count this developer (and his users) as loyal sweet alerters.

@inctor
Copy link
Author

inctor commented Nov 19, 2015

Sadly it feels like this project has been abandoned.
Even the clone SweetAlert2, still have these bugs and no updates for a really long time.

It's really a shame, that it's been abandoned, since it's a really nice project!

But 121 open issues and 37 un-merged PR's. It's unlikely it'll be fixed or getting updates soon.

However, there is change with the possibility of #457 , which seems to be able to handle this primary issue.

@kentmw
Copy link

kentmw commented Nov 19, 2015

@inctor, @Charlex I wrote up a guide on how to use the code addition I wrote to do this at #457. Because it adds on top of the existing sweetalert library, it doesn't require merging into the project/updating the library code. If you have thoughts to make it better let me know.

@hcharley
Copy link

@kentmw Hero. I'll give it a go and see if I run into any pain.

@limonte
Copy link

limonte commented Jun 7, 2016

SweetAlert2 supports modals queue: https://sweetalert2.github.io/#chaining-modals

@pararrayos
Copy link

I have the same problem as above. If anyone find this useful:

swal({
			//whatever parameters in first sweet alert
	},
        function(){
                        setTimeout(function(){
                             swal({	//whatever parameters in second sweet alert});
                       }, time);
     });

To avoid sweet alert to 'freeze' when chaining two or more alerts, just add a minor timeout. Maybe not the most fancy solution but it worked for me.

@fahmilatib
Copy link

@pararrayos bit hacky but can be useful as a temporary fix

@t4t5
Copy link
Owner

t4t5 commented Sep 8, 2017

Sorry for such a long delay people. These issues should now be fixed in SweetAlert 2.0, which uses promises!

@t4t5 t4t5 closed this as completed Sep 8, 2017
@fahmilatib
Copy link

Thank you so much for the update @t4t5 . Lovin' the new website layout BTW!

@gongiskhan
Copy link

If anyone stumbles uppon this and also getting undefined when calling swal (probably older versions). Here's how I worked around it:

if(notifications.length > 1) {
            var i = 0;
            function displayNext(){
                swal({title: notifications[i].title, text: notifications[i].body, type: 'info', closeOnConfirm:true}, function(){
                    if(i < notifications.length){
                        setTimeout(function(){
                            displayNext();
                        },500);
                    }
                });
                i++;
            }
            displayNext();
        }

@Rakesh-webdeveloper
Copy link

yes this fix only for the temporary. but it's ok

@joneshwangoo
Copy link

@pararrayos thanks..!!!

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

10 participants