【问题标题】:uncaught TypeError: object is not a function (anonymous function) in grails未捕获的类型错误:对象不是 grails 中的函数(匿名函数)
【发布时间】:2013-08-27 06:53:45
【问题描述】:

在我的 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: object is not a function(匿名函数)。解决办法是什么?

【问题讨论】:

    标签: jquery grails gsp


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2016-07-12
      • 1970-01-01
      • 1970-01-01
      • 2014-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多