【问题标题】:drupal jquery error: Uncaught TypeError: undefined is not a functiondrupal jquery错误:未捕获的TypeError:未定义不是函数
【发布时间】:2014-07-04 15:51:51
【问题描述】:

我正在尝试在Drupal 7 中使用jquery。我已将以下代码放入模块js 文件中,并使用drupal_add_js 加载它。起初,我的模块js 文件中发生了同样的错误,在谷歌搜索后我发现我应该将代码包装在一个函数中。但修复后,错误发生在jquery.js?v=1.4.4。这是我的代码:

(function($) {
$(document).mouseup(function (e)
{
    var container = $("div#top-bar-menu-wrapper");

    if (!container.is(e.target) // if the target of the click isn't the container...
        && container.has(e.target).length === 0) // ... nor a descendant of the container
    {
        container.hide();
    }
});
}(jQuery));

以及错误截图:

【问题讨论】:

    标签: jquery drupal-7


    【解决方案1】:

    问题出在这一行:

    container.is(e.target)
    

    jQuery.is() 已将 元素 作为参数。这在 jQuery 1.6 中是可以的

    所以一个 jquery 更新解决了我的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 2015-03-24
      • 2021-05-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-03
      • 2016-03-21
      相关资源
      最近更新 更多