jGrowl:如何将我的界面一次限制为一条消息?
鉴于:我在页面加载时加载消息队列。
使用 jGrowl,我如何以滴水般的方式显示每条消息,一次一条消息?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几个月前,我需要为一个项目执行此操作。如果您使用最新的 jGrowl(截至撰写本文时为 1.2.0)中提供的池功能,您可以简单地编写:
这样,您可以同时加载所有这些,jGrowl 将只在以下位置显示一个:一次。当一条消息关闭时,jGrowl 将自动显示下一条消息。
我希望这就是你想要的。
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:
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.
$.jGrowl.defaults.pool == 0;
if ( $(this.element).find('div.jGrowl-notification:parent').size() < 0 ) {
目前正在处理站点通知,我找不到一种一次显示一个通知的方法,直到我找到了这个页面。
谢谢布鲁诺!你救了我。 :)
$.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. :)
由于您指定了消息显示的时间间隔(最大),因此您可以简单地使用 JS setTimeout 以相同的时间间隔循环遍历数组,创建一条新消息。
或者,jGrowl 可以将函数(e,m,o) 作为其 close 参数,并且每当消息关闭时它将使用它作为回调。在此函数中,从队列中创建一条新消息,然后您就应该完成设置。请参阅文档此处。
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.