52

I've been playing with toastr and have successfully set the timeout to 0 so the toast remains sticky, however the toast disappears when I mouse out of the toast. I'd like to override this so the toast only goes away if the user clicks it - ideal for toasts with lots of text. How can this be done?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
SB2055
  • 12,272
  • 32
  • 97
  • 202

3 Answers3

69

Set extendedTimeOut to 0 too. That will keep it sticky.

Zyo
  • 1,934
  • 21
  • 25
John Papa
  • 21,880
  • 4
  • 61
  • 60
  • I'm really enjoying `Toastr` in a current project. Thanks John for all the work you give away to the community. – Leniel Maccaferri Aug 29 '14 at 23:23
  • 3
    This seems to be case sensitive: ` "timeOut": "0", "extendedTimeOut": "0"` – Vitalik Sep 08 '14 at 12:56
  • @JohnPapa - I'm heavily using toastr in my project, its awesome. I'm facing one issue with sticky toastr. Could you please help me with how I can close a sticky toastr? I have a button in the sticky toast and I want to close the toast once user click on that button. In the button click event I have used ' toastr.options.timeOut = 5;' but the toastr is not disappearing. Thanks in advance. – Pritam Karmakar May 02 '16 at 17:28
  • 1
    `timeout` also needs to be set to `0`!! – Adam Nov 05 '17 at 00:05
29

timeOut and extendedTimeOut must be set to 0.

Here is a complete example:

toastr.options = {
    timeOut: 0,
    extendedTimeOut: 0
};

toastr.info("Testing <button>blah</button>");

For those who wish to not close the toast on click, the example changes to:

toastr.options = {
    timeOut: 0,
    extendedTimeOut: 0,
    tapToDismiss: false
};

toastr.info("Testing <button>blah</button>");
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
rynop
  • 50,086
  • 26
  • 101
  • 112
2

you could also use disableTimeOut as an alternative to setting both timeOut and extendedTimeOut to 0.

toastr.options = {
    disableTimeOut : true, //Equivalent ot timeOut: 0 and extendedTimeOut: 0
}
Badr Errami
  • 136
  • 3