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

Ht.swalCloseEventFinishedCallback when closing after a swal update. #1778

Closed
giazach opened this issue Oct 18, 2019 · 3 comments · Fixed by #1779
Closed

Ht.swalCloseEventFinishedCallback when closing after a swal update. #1778

giazach opened this issue Oct 18, 2019 · 3 comments · Fixed by #1779
Labels

Comments

@giazach
Copy link

giazach commented Oct 18, 2019

When closing a Swal.update after a Swal.fire, there is an error triggered
[error: Ht.swalCloseEventFinishedCallback is not a function]

Live demo

  Swal.fire({
        type: "question",
        title: "Are you sure?",
        showCancelButton: true,
        showLoaderOnConfirm: true,
        preConfirm: () => {
            return true;
        }
    }).then((result) => {
        if(result.value){
            Swal.update({
                type: 'success',
                title: 'Success!',
                showConfirmButton : false,
                showCancelButton  : false,
            });
            setTimeout(function(){ Swal.close();  }, 1000);
        }
    });

In my case, there is no script/process disruption except the console warning.

@limonte
Copy link
Member

limonte commented Oct 18, 2019

You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter:

  Swal.fire({
      type: "question",
      title: "Are you sure?",
      showCancelButton: true,
      showLoaderOnConfirm: true,
      preConfirm: (result) => {
        Swal.update({
            type: 'success',
            title: 'Success!',
            showConfirmButton : false,
            showCancelButton  : false,
        });
        setTimeout(function(){ Swal.close();  }, 1000);
        return false;
      }
  })

@giazach
Copy link
Author

giazach commented Oct 18, 2019

The preConfirm have a ajax response like: (full script)

Swal.fire({type: "question",
    title: "Are you sure?",
    showCancelButton: true,
    showLoaderOnConfirm: true,
    preConfirm: () => {
        return $.post($that.attr('href'), null, null, 'json').catch(function() {return false;});
    }
}).then((result) => {
    if(result.value){
        Swal.update({
            type: 'success',
            title: 'Success!',
            showConfirmButton : false,
            showCancelButton  : false,
        });
        setTimeout(function(){ Swal.close();  }, 1000);
    }
});

and if there is no Swal.close(). the dialog stays opened.
I might miss something and detach the whole ajax response into preConfirm as suggested.
(the warning is triggered for both scripts provided)
Thank you for your time!
`

@limonte
Copy link
Member

limonte commented Oct 18, 2019

🎉 This issue has been resolved in version 8.18.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants