2012-05-30 57 views
4

我使用noty以使用'右上'警報設置顯示通知。我對jquery真的很陌生,但知道php和mysql足以獲得我想要做的大部分事情。顯示延遲多個Noty通知

我想要做的就是使用mySQL來獲取數據,看看用戶是否需要顯示任何通知(完成)。然後在頁面加載時顯示該通知,我也這樣做了,儘管我確定除了重複代碼外,還有一種更優雅的方式來顯示多個通知?

然後,我想對每個通知出現延遲說1秒,以便它們不會一次全部彈出,並在同一時間消失。我已經看過.delay(),但不知道jQuery好一點,它對我來說毫無用處。

我的代碼:

$(document).ready(function() { 
    var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); 
    var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); 
}); 

回答

2

你可以只使用setTimeout()本地JavaScript功能。這會在給定的超時時間後(毫秒)排隊。

$(document).ready(function() { 
    var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); 
    setTimeout(function() { var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); }, 5000) 
}); 

您可能會發現jQuery Pines更好的通知系統排隊多個通知。

+0

有沒有功能只是說noty_id.show() –