t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

Button keeps loading on second submit after first stopLoading() #827

Open ghost opened 6 years ago

ghost commented 6 years ago

I think this is a bug, the button just keeps loading in the second request after firing the stopLoading() method, here's the code:

swal("Change Password", "Enter your desired new password:", {
        content: {
            element: "input",
            attributes: {
                placeholder: "New password",
                type: "password",
            },
        },
        button: {
            text: "Submit",
            closeModal: false,
        }
    })
    .then((value) => {
        if (value == "") {
            iziToast.show({
                icon: "fa fa-exclamation-circle",
                title: 'Warning',
                message: 'Password cannot be empty!',
                position: "topLeft"
            });
            swal.stopLoading();
        } else {
            $.ajax({
                url: site_url + "/ajaxMain/forgot/?newpassword=" + value,
                type: "GET",
                success: function(result) {
                    var data = JSON.parse(result);
                    if (data.status === "success") {
                        swal({
                            title: "Success!",
                            text: "Your  password has been successfully changed! Logging in..",
                            icon: "success",
                            closeOnClickOutside: false,
                            button: false
                        });
                        setInterval(function() {
                            window.location = site_url;
                        }, 3000);
                    } else {
                        swal("Change Failed", "Something went wrong while trying to change your password!", "error");
                    }
                }
            });
        }
    });
aasjpvm commented 5 years ago

https://github.com/t4t5/sweetalert/issues/795