jQuery错误TypeError:$ .event.handle未定义 [英] jQuery error TypeError: $.event.handle is undefined
问题描述
我正在使用最新的jQuery for jQuery.masonry抛出以下错误:在jquery-1.9.1.min.js的第47行
I am using latest jQuery for jQuery.masonry its throwing following error: on line 47 in jquery-1.9.1.min.js
TypeError: $.event.handle is undefined
如果有任何一个有相同的错误?
if any one is having same error ?
MyCode:
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/scripts/jquery-1.9.1.min.js"></script>
<script language="javascript" src="http://masonry.desandro.com/jquery.masonry.min.js"></script>
<script src="http://masonry.desandro.com/js/jquery.infinitescroll.min.js"></script>
<script>
$(function(){
var $container = $('#content');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.post',
isAnimated: true
});
});
$container.infinitescroll({
navSelector : '.wp-pagenavi', // selector for the paged navigation
nextSelector : '.wp-pagenavi a', // selector for the NEXT link (to page 2)
itemSelector : '.post', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
img: 'http://i.imgur.com/6RMhx.gif'
}
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});
</script>
推荐答案
该函数已被弃用:http://jquery.com/upgrade-guide/1.9/#other-undocumented-properties-and-methods
您可以改为使用$ .event.dispatch。
You can use $.event.dispatch instead.
此外或使用您可以添加迁移插件的调度功能, http:// blog .jquery.com / 2013/05/01 / jquery-migrate-1-2-0-released / ,它将以$ .event.handle重新添加,这样您就可以在不破坏应用程序的情况下修复代码。
In addition or alternatively to using the dispatch function you can add the Migrate plugin, http://blog.jquery.com/2013/05/01/jquery-migrate-1-2-0-released/, which will add back in $.event.handle so you able to fix the code without breaking the application.
这篇关于jQuery错误TypeError:$ .event.handle未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!