CodeSeven / toastr

Simple javascript toast notifications
http://www.toastrjs.com
MIT License
11.96k stars 2.04k forks source link

Unique Id for Indeterminate Toast #636

Closed TorreyGarland closed 2 years ago

TorreyGarland commented 4 years ago

Is there a way to uniquely identify an interdeterminate toast?

I have a potentially long running Ajax operation and I want to be able to close specific toasts, similar to the way that gritter does.

EstesE commented 2 years ago

Add this to the notify function in toastr.js:

function setID() {     if (options.id)$toastElement.attr('id', options.id); }

Then add the setID to the personalizeToast function in toastr.js:

function personalizeToast() {     setIcon();     setTitle();     setMessage();     setCloseButton();     setProgressBar();     setRTL();     setID();     setSequence();     setAria(); }

Then pass an id in the options:

toastr.options.id = guidFor({}); toastr.info('Have fun storming the castle!', 'Miracle Max Says');