CodeSeven / toastr

Simple javascript toast notifications

Home Page:http://www.toastrjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unique Id for Indeterminate Toast

TorreyGarland opened this issue · comments

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.

commented

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');