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=".masonry.min.js"></script>
<script src=".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: '.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>
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>
Share
Improve this question
asked May 13, 2013 at 17:22
justnajmjustnajm
4,5346 gold badges38 silver badges56 bronze badges
2
- 2 It seems that masonry does not work with jQuery 1.9 because $.event.handle returns undefined. A link to a github with all the info you need. – Ohgodwhy Commented May 13, 2013 at 17:27
- Yes I think you are right as I have seen that with old liberary its not the issues, but another one that is too much recursive error – justnajm Commented May 13, 2013 at 17:36
2 Answers
Reset to default 19The function has been deprecated: http://jquery.com/upgrade-guide/1.9/#other-undocumented-properties-and-methods
You can use $.event.dispatch instead.
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.
You are trying to use :
var $newElems = $( newElements ).css({ opacity: 0 });
as an element :
$newElems.imagesLoaded
Maybe this is the problem.
A solution would be :
var $newElems = $( newElements );
$newElems.css({ opacity: 0 });