开发者

How to show number of jgrowl notfications?

开发者 https://www.devze.com 2023-01-03 03:12 出处:网络
I am using a pool of 5 with jquery. So only 5 notifications should be shown. I think it would be nice to have maybe under the \"close all\" button to have a count like shown 5 of 20 notifications.

I am using a pool of 5 with jquery. So only 5 notifications should be shown. I think it would be nice to have maybe under the "close all" button to have a count like shown 5 of 20 notifications.

To me it could get confusing if I keep closing notificat开发者_StackOverflow中文版ions and new ones keep poping up. I might think there is some sort of problem with the site.

Anyone know how to do this?


You can store number of open notifications in global variable and increase/decrease/display it by custom function called in jgrowl events: beforeOpen/open and beforeClose/close ie:

var opened = 0;

function counter(i)
{
    opened += i;
    $('#closeAllContainer span.counter').text(opened);
}

$.jGrowl("Lorem Ipsum", {
    beforeClose: function(){ counter(-1); },
    beforeOpen:  function(){ counter(1); }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消