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

Programmatic control over popups? #117

Open
andregreeff opened this issue Apr 1, 2023 · 0 comments
Open

Programmatic control over popups? #117

andregreeff opened this issue Apr 1, 2023 · 0 comments

Comments

@andregreeff
Copy link

I've used ToastifyJS in a number of small projects so far, it's beautifully simple to use and easy to implement.. but now I find myself needing a little more functionality than I have previously.

I have a feeling that I know the answer to my question already, but in part just to confirm, and in part to (hopefully) plant a seed for possible future improvement: is it possible to control the ToastifyJS popups programmatically?

for example:

  • show a persistent notification
  • dynamically update the message shown in a specific notification
  • dismiss a specific notification from a separate function

my first thought was to render the notification with a unique ID, and then find and manipulate that DOM node from my own custom code.. but this would introduce two rather serious problems:

firstly, it requires a great deal of very specific business logic. which would depend directly on the current DOM structure, and would obviously be prone to break with even minor library changes.

secondly, while I can target and manipulate the DOM nodes, this would not give me access to the methods from the Toastify object itself, so I wouldn't be able to use the hideToast method from outside of the code that handles toast creation, and would instead need to locate the toast and call removeChild myself.

@apvarun, would you consider adding this sort of functionality to ToastifyJS at some point?

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

1 participant