如何在特定计数后停止Gritter通知

时间:2015-11-21 15:06:13

标签: javascript jquery

[我不希望在特定计数之后包含gritter通知,当我关闭警报时,当我再次点击同一警报时,应该还原,使用javascript,jquery和servlets。]

var showgritter= false;
var catList = [];
var catID;
var pid;
var p=[];
var pidsList=[];
var newList=[];

//function fetches the different categories
function getCategory()
{ 
    $('#category').empty();
    $.ajax
    ({
        url: "GetCategoryServlet",
        dataType: "json",
        success: function (data) 
        {

            var src = "";
            var roleId = data[0].roleId;    

            if(roleId === 2)
            {
                $.each(data, function (id, cat_obj) 
                {   catID=cat_obj.categoryId;
                    var posts=cat_obj.posts;
                    var count = cat_obj.pendingCount;
                    src = src + "<div id='maindiv' class='wrapperss' ><img  onclick=main_img('"+cat_obj.categoryId+"') style='margin-left:50px; margin-right:0.5px;'  src='" + cat_obj.imageLocation + "' width='100px' cid ='"+ cat_obj.categoryId +"' title='"+cat_obj.type+"' />\n\
                                     <span id='extra' >\n\
                                     <img  onclick=delcat('"+cat_obj.categoryId+"') src='images/delete.png' style='margin-right:5px' title='Delete Category'/>\n\
                                     <img  onclick=pop('category_div','addcategory.jsp') src='images/edit.png' title='Edit Category'>\n\
                                     </span>";


                        if(count > 0)
                        $.each(posts, function (id1, post_obj) 
                        {

                                pids= post_obj.postId;
                                pidsList.push(pids.toString());
                                src = src + "<img class='noticlass' id='notify' onclick=alert_func('"+cat_obj.categoryId+"','"+count+"') src='images/redcircle.png'  value='"+cat_obj.pendingCount+"' title='Pending Posts'/>\n\
                                             <div class='pendingclass' title='Pending Posts' onclick=alert_func('"+cat_obj.categoryId+"','"+count+"')>"+cat_obj.pendingCount+"</div>";
                        }); 
                        src = src + "</div>";  
                });       
            } 
            else 
            {
                $.each(data, function (id, cat_obj) 
                {
                    src = src + "<div id='userdiv' class='cat_images'><img  onclick=main_img('"+cat_obj.categoryId+"')  style='margin-left:50px; margin-right:0.5px;' src='" + cat_obj.imageLocation + "' width='100px' cid ='"+ cat_obj.categoryId +"' title='"+cat_obj.type+"'/>\n\
                                <span id='userextra'> \n\
                                <img onclick=unsubs('"+cat_obj.categoryId+"') src='images/blockk.png' title='Unsubscribe'>\n\
                                </span>\n\
                                </div>";            
                });
            }
                $('#category').html(src);
        }
    });  
    return false; 
}

//for making the growl like notification of pending posts
function alert_func(obj,pc){

     $.ajax({   
        url : 'PostApprove',
        dataType: 'json',
        data: 
        {
            category_id: obj
        },
        success: function(data)
        { 
            var count = 1;
            $.each(data, function (id, post_obj) {   
            $.gritter.add({
                             position: 'bottom-left',
                             title : post_obj.title,
                             time : 0,
                             sticky: true,
                             text : post_obj.description+ "<br></br>\n\
                                     <input type='submit' style='margin-left:50%' onclick=approve('"+post_obj.postId+"','"+count+"'); name='approve' class='button_approve' value='Approve' />\n\
                                     <input type='submit' onclick=reject('"+post_obj.postId+"','"+count+"') name='reject' class='button_reject' value='Reject' />\n\
                                    "            
                           });
                             count++; 
                       });  
        }
    });             
 } 

// Clicking (X) makes the perdy thing close and this is in the `jqueru.gritter.js file function`
            $(item).find('.gritter-close').click(function(){

                           // catList.pop(catID.toString());
                Gritter.removeSpecific(number, {}, null, true);
            });
            return number;

1http://i.stack.imgur.com/mmrOs.pnScreenshot Gritter通知屏幕.Pending计数为红色圆圈,同样没有。警报以gritter通知的形式出现。

0 个答案:

没有答案