未捕获TypeError:对象不是grails中的函数(匿名函数)

时间:2013-08-27 06:53:45

标签: jquery grails gsp

在我的gsp中,我有以下代码。

$ = 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);

运行时,它会给出类似未捕获的TypeError:对象不是函数(匿名函数)。解决方案是什么?

1 个答案:

答案 0 :(得分:1)

您要将jQuery分配给$而不是j$,之后您使用j$来引用jQuery,但j$没有赋值给// 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

应该是

{{1}}
相关问题