I´m trying to keep toastr open alway but it´s dissapear when I click on it, I set extendedTimeOut = 0 , however the toastr dissapear when click on it, so I need a way it never closes even when I make click on it
Asked
Active
Viewed 1.2k times
12
-
1add some code so we'll can play with it. – Dvir Nov 09 '15 at 22:32
3 Answers
31
I found a toastr option to do it
toastr.options.tapToDismiss = false
Example: https://jsfiddle.net/w96udv4e/5/

srd98
- 623
- 1
- 6
- 12
-
This works ! But why doesn't it appear in chrome console auto-fill options ? – YetAnotherBot Apr 11 '18 at 10:28
-
Just an addition, but I add my toastr configuration to the shared _layout page; just so people have an extra option! – else Jun 09 '23 at 09:30
0
try to add
event.stopPropogation()
upd code link
UPD: in sources it triggers
return $toastElement[options.hideMethod](...);
so you need to set this options to jquery function that will work on $toastElement, that makes nothing, something like an 'end' function, but you can make a noop function over all jquery elements and make hideMethod equals 'noop':
$.fn.noop = function(){return this;};
toastr.options.hideMethod = 'noop';

Danil Gudz
- 2,233
- 16
- 16
-
I have tried but it doesn´t works $("#toast-container").on("click",function(event){ event.stopPropagation() }); – srd98 Nov 09 '15 at 22:50
-
It works but return a Javascript Error : "Uncaught TypeError: Cannot read property 'stopPropogation' of undefined" so the idea is that it works without errors – srd98 Nov 10 '15 at 13:29
-
set toastr.options.hideMethod = 'end'; it's just like noop on click. I looked at source code and saw that on click it triggers $toastElement[options.hideMethod], so you need to set this option to such operation as noop function – Danil Gudz Nov 10 '15 at 16:33
0
Only thing that worked for me was setting "tapToDismiss"= false
and updating the toastr script:
toastr.options.tapToDismiss = false
Line 273 in toastr.js:
if (options.onclick) {
$toastElement.click(function () {
options.onclick();
if (options.tapToDismiss) hideToast(); // Line that hides toast.
});
}

Austen Holland
- 1,828
- 1
- 15
- 24

Andrew Gale
- 61
- 3