$.gritter is coming as undefined?

931 views Asked by At

My program uses jquery.gritter plugin to show error and success messages. In the whole application is working perfectly. But only at one place it is showing "Cannot read property 'add' of undefined" for the below code:

$(".cart").on("click", function(){
        if($("#cartCount").html()==""){
            $.gritter.add({
                title: "Cart",
                text: "Cart is empty", class_name: 'gritter-red',
                fade_in_speed: 100, fade_out_speed: 100,
                sticky: true, time: '2000'
            });
        }
    });

I have this code in header.jsp and the header.jsp is included on the main page. The main page is having the import of jquery.gritter.js.

The main page has other included jsp pages where we are using gritter functionality and they are working fine. I tried by including the gritter plugin inside header.jsp as well but it did not work. My application is a Spring MVC application.

How can this be resolved?

0

There are 0 answers