【发布时间】:2015-02-06 13:17:32
【问题描述】:
我正在使用Toastr 2.1 JavaScript 库来显示瞬时用户输入验证错误消息。我将preventDuplicates 选项设置为true。它不起作用 - 当用户快速连续单击验证按钮时,我仍然看到重复的消息(点击比“超时”更快)。
这是我的 toastr 默认设置:
function getDefaults() {
return {
tapToDismiss: true,
toastClass: 'toast',
containerId: 'toast-container',
debug: false,
showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
showDuration: 300,
showEasing: 'swing', //swing and linear are built into jQuery
onShown: undefined,
hideMethod: 'fadeOut',
hideDuration: 1000,
hideEasing: 'swing',
onHidden: undefined,
extendedTimeOut: 1000,
iconClasses: {
error: 'toast-error',
info: 'toast-info',
success: 'toast-success',
warning: 'toast-warning'
},
iconClass: 'toast-info',
positionClass: 'toast-top-right',
timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
titleClass: 'toast-title',
messageClass: 'toast-message',
target: 'body',
closeHtml: '<button>×</button>',
newestOnTop: true,
preventDuplicates: true,
progressBar: false
};
}
我是否需要进行任何其他更改以防止出现重复的错误消息?
【问题讨论】:
-
为什么用户快速连续点击验证按钮?
-
用户可以进行更改并再次单击验证按钮,此持续时间可能比 toastr 消息超时时间短。
-
这里有什么更新吗?你设法解决了这个问题吗? CodeSeven 上的演示运行良好,但我似乎也无法在我的项目中使用它。
标签: javascript toastr