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

External close Toast - dismiss toast #91

Open
Shaka-60hp opened this issue Nov 20, 2021 · 2 comments
Open

External close Toast - dismiss toast #91

Shaka-60hp opened this issue Nov 20, 2021 · 2 comments

Comments

@Shaka-60hp
Copy link

Hi,
first of all thank you guys
I wonder if there is a way or function to dismiss the toas from outside the toast,
like the close button but external to th toast

If there is, please add the function to the documentation and some example if posible
Thanks !!

@pavlexander
Copy link

I would also like something similar.. I was wondering if you could close the toast by clicking on it? (as opposed to waiting for it to close automatically or clicking on a small close button).

I tried doing the following:

      Toastify({
        text: "This is a toast",
        duration: 2000,
        close: false,
        stopOnFocus: true,
        onClick: function () {
          this.dismiss();
          this.hide();
          this.hideToast();
          this.destroy();
          this.close();
          this.dispose();
        },
      }).showToast();

but there is no dismiss function, no hide/hideToast/destroy/close/dispose (like OP wants as well). If the function was there then the OP could probably reference the instance and call the method on it.. In my case I just want the toast the close on click...

@pavlexander
Copy link

pavlexander commented Jan 4, 2022

nvm I figured it out

      var toast = Toastify({
        text: "This is a toast",
        duration: 2000,
        close: false,
        stopOnFocus: true,
        onClick: function () {
          toast.hideToast();
        },
      });

      toast.showToast();

so just keep the toast reference and invoke the toast.hideToast(); when you want it to be closed.

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

2 participants