jGrowl: How can I limit my interface to one message at a time?

≡放荡痞女 提交于 2019-12-10 18:32:02

问题


Given: I load a queue of messages at page load.

With jGrowl, how can I display each message, one message at a time, in a drip-like fashion?


回答1:


I needed to do this for a project, a few months ago. If you use the pooling feature, available in the latest jGrowl (1.2.0 as of this writing), you can simply write:

$.jGrowl.defaults.pool = 1;

That way, you can load all of them at the same time, jGrowl will take care of only showing one at a time. When a message closes, jGrowl will automatically display the next one.

I hope this is what you wanted.




回答2:


$.jGrowl.defaults.pool == 0;

if ( $(this.element).find('div.jGrowl-notification:parent').size() < 0 ) {

Currently working on site notifications, I couldn't find a way to show one at a time until I found this page. Thanks Bruno! You saved me. :)




回答3:


Since you specify the time interval that a message is displayed for (at maximum), you could simply use a JS setTimeout to loop through an array at the same interval, creating a new message.

Alternatively, jGrowl can take a function(e,m,o) as its close parameter, and it will use it as a callback whenever a message is closed. In this function, create a new message from your queue and you should be set. See documentation here.



来源:https://stackoverflow.com/questions/1327527/jgrowl-how-can-i-limit-my-interface-to-one-message-at-a-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!