So, I use jQuery Masonry, and I want to call some jQuery every time it loads messages:
function manipulate(id) { $(id).each(function(){ if($(this).height()>200){ $('#container2').append(this); } else{ $('#container').append(this); }; }); };
Therefore, I want to call this function every time when the next element is loaded in the Freemasonry container. Thus, he correctly manipulates the object. How to do it?
Update: Freemasonry Description
Freemasonry is a Javascript plugin that looks like CSS floats making it blend perfectly + endless scrolling. It completely hides everything that would not be on page 1, if there were no endless scrolling, and then loads them when necessary. This means that my function will not affect any of the hidden elements and should be called when Freemasonry loads the next set of elements so that they appear in the right places. This may mean that, not knowing Freemasonry, you cannot solve my problem, but you can still. And finally, Freemasonry “attaches” objects to the container of Freemasonry, and then “shows” them. Therefore, I assume that I need to do this by adding them to the correct containers after they have been added to the Masonry container, but not yet appear.
Masonry Code:
$(window).load(function(){ var $wall = $('#container'); $wall.imagesLoaded(function(){ $wall.masonry({ itemSelector: '#entry, #entry_photo', isAnimated : false }); }); $wall.infinitescroll({ navSelector : '#page-nav', nextSelector : '#page-nav a', itemSelector : '.entry, .entry_photo', bufferPx : 2000, debug : false, errorCallback: function() { $('#infscr-loading').fadeOut('normal'); }}, function(newElements) { var $newElems = $(newElements); $newElems.hide(); $newElems.imagesLoaded(function(){ $wall.masonry( 'appended', $newElems,{isAnimated: false}, function(){$newElems.fadeIn('slow');} ); }); }); $('.entry').show(500); });
I tried to put the function in Freemasonry blocks, and even as a function of $newElems , to see if it would work when loading more images, but this is not the case and actually breaks it a bit.
How can I get it to start all new elements loaded by Freemasonry through my jQuery so that they are added to the correct container?