Programmatic control over popups?
andregreeff opened this issue · 0 comments
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?