Visme
Visme

Reputation: 983

uncaught TypeError: object is not a function (anonymous function) in grails

In my gsp, i have the following code.

$ = jQuery.noConflict();
      j$(function($){
          j$(document).ready(function(){
              j$('#news-container').vTicker({
                  speed: 500,
                  pause: 3000,
                  animation: 'fade',
                  mousePause: true,
                  showItems: 1
              });
              j$(document).keydown(function(event) {
                  $("#helpLinkId").hide();
              });
          });
      })(jQuery);

When run, it gives like uncaught TypeError: object is not a function (anonymous function). What is the solution for this?

Upvotes: 0

Views: 1392

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

You are assigning jQuery to $ instead of j$ and later you are using j$ to refer to jQuery, but j$ has no value assigned to it

it should be

// instead of assigning jQuery to $ you need to assign it to j$
j$ = jQuery.noConflict();
j$(function($) {
    j$(document).ready(function() {
        j$('#news-container').vTicker({
            speed : 500,
            pause : 3000,
            animation : 'fade',
            mousePause : true,
            showItems : 1
        });
        j$(document).keydown(function(event) {
            $("#helpLinkId").hide();
        });
    });
});//there is no need to pass jQuery here

Upvotes: 1

Related Questions