当消息列表喂了jQuery插件noty超时不工作。我从servlet获得消息列表,然后像这样调用noty。noty jQuery插件超时没有发生
<script>
function callNotification()
{
<c:foreach var = "message" items = "${sessionScope.notification}">
notify('${message}');
</c:foreach>
}
function notify(message)
{
noty({
"text": message,
"theme": noty_theme_facebook",
"layout": topRight,
"information","animateOpen":{"height":"toggle"},
"information","animateOpen":{"height":"toggle"},
"speed":500,
"timeout":5000,
"closeButton":true,
"closeOnSelfClick":true,
"closeOnSelfOver":false,
"modal":false
})
</script>
理想情况下,这应该在消息上循环并以5000ms的超时值打印它们。但是这会一次打印所有的信息。我进一步尝试使用JavaScript原生的setTimeout功能,取代了我的callNotification与此有关。
function callNotification()
{
<c:foreach var = "message" items = "${sessionScope.notification}">
(function(message){
setTimeout(function(){notify('${message}');},5000)
}('${message}')
}}
</c:foreach>
}
但是这也被证明是无效的。奇怪的是超时似乎当我更换"layout":center
通知方法做工精细。我哪里错了。我要与时间被显示出来的5秒钟后,第一消息被自动地删除的消息和下一个显示出来。
你有没有想出解决办法? – ashes999 2013-06-21 09:58:09
您使用的是promise.js文件吗? – MaFo 2014-09-04 10:58:47
有没有试过关闭选项 – 2016-02-24 12:26:03