防止点击关闭 Toastr
Prevent close Toastr on Click
我试图让 toastr 始终保持打开状态,但是当我点击它时它消失了,我设置了 extendedTimeOut = 0 ,但是当点击它时 toastr 消失了,所以我需要一种它永远不会关闭的方法,即使当我点击它
尝试添加
event.stopPropogation()
更新:
在来源中它触发
return $toastElement[options.hideMethod](...);
所以你需要将这个选项设置为 jquery 函数,它将在 $toastElement 上工作,它什么都不做,类似于 'end' 函数,但你可以在所有 jquery 元素并使 hideMethod 等于 'noop':
$.fn.noop = function(){return this;};
toastr.options.hideMethod = 'noop';
我找到了一个烤面包机选项
toastr.options.tapToDismiss = false
唯一对我有用的是设置 "tapToDismiss"= false
和更新 toastr 脚本:
toastr.options.tapToDismiss = false
toastr.js 中的第 273 行:
if (options.onclick) {
$toastElement.click(function () {
options.onclick();
if (options.tapToDismiss) hideToast(); // Line that hides toast.
});
}
我试图让 toastr 始终保持打开状态,但是当我点击它时它消失了,我设置了 extendedTimeOut = 0 ,但是当点击它时 toastr 消失了,所以我需要一种它永远不会关闭的方法,即使当我点击它
尝试添加
event.stopPropogation()
更新: 在来源中它触发
return $toastElement[options.hideMethod](...);
所以你需要将这个选项设置为 jquery 函数,它将在 $toastElement 上工作,它什么都不做,类似于 'end' 函数,但你可以在所有 jquery 元素并使 hideMethod 等于 'noop':
$.fn.noop = function(){return this;};
toastr.options.hideMethod = 'noop';
我找到了一个烤面包机选项
toastr.options.tapToDismiss = false
唯一对我有用的是设置 "tapToDismiss"= false
和更新 toastr 脚本:
toastr.options.tapToDismiss = false
toastr.js 中的第 273 行:
if (options.onclick) {
$toastElement.click(function () {
options.onclick();
if (options.tapToDismiss) hideToast(); // Line that hides toast.
});
}