另一个'未捕获的TypeError:无法调用方法'应用'未定义'

时间:2013-03-14 16:41:31

标签: javascript debugging function typeerror

我的机会很渺茫,但我已经通过Google尝试了几个解决方案,但似乎没有解决'未捕获的TypeError:无法调用方法'应用'未定义',匿名函数:

enter image description here

如果它本身没有其他JS,它可以工作,但当与其他脚本组合在同一页面上时,我会收到错误。

它引用的代码行如下,第32行是罪魁祸首。第32行是这一行 - if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }

var $event = $.event, resizeTimeout;

    $event.special.smartresize  = {
        setup: function() {
            $(this).bind( "resize", $event.special.smartresize.handler );
        },
        teardown: function() {
            $(this).unbind( "resize", $event.special.smartresize.handler );
        },
        handler: function( event, execAsap ) {
            // Save the context
            var context = this,
                args    = arguments;

            // set correct event type
            event.type = "smartresize";

            if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
            resizeTimeout = setTimeout(function() {
                jQuery.event.handle.apply( context, args );
            }, execAsap === "execAsap"? 0 : 100 );
        }
    };

5 个答案:

答案 0 :(得分:10)

我设法通过查看代码来解决这个问题,有一个名为“模拟”的方法,您可以使用它来“在捐赠者事件上捎带来模拟不同的一个。”,“假的原始事件以避免捐赠者的停止传播,但如果模拟事件阻止了默认,那么我们就会对捐赠者做同样的事情。“这让我感到震惊,因为“在Brandon Aaron的教程中设置事件类型

而不是:

event.type = "myType";
jQuery.event.handle.apply(this, arguments);

使用:

jQuery.event.simulate('myType', this, event);

答案 1 :(得分:5)

猜测你正在加载更新版本的jQuery。看起来似乎jQuery 1.9及更高版本没有jQuery.event.handle属性。

据我所知,这从来都不是受支持的财产。

http://jsfiddle.net/xPJN4/

答案 2 :(得分:0)

我在脑中意外加载了jquery的最新版本时遇到了此错误,然后在其后加载了jquery的旧版本。旧版本没有我需要的新版本的方法。

答案 3 :(得分:0)

使用旧版本的jQuery和masonry.min.js时出现此错误 - 我不再使用未缩小的代码!

更换:

b.event.handle.apply(d,f)

使用

b.event.simulate('smartresize', d, f)

对问题进行排序,脚本现在工作正常,感谢@ karl-forshaw的修复...我会在重播中发表评论,但缺乏这样做的声誉!

答案 4 :(得分:0)

当我链接到jQuery Migrate时,我的错误已修复。

JQMIGRATE:已安装迁移版本1.4.1

没有更多错误。对我来说,isotope.js导致了这个问题。希望它能帮助随机的人。 :)

相关问题