I have an xml file which contains a list of images, I wish to load these images into a container and then apply masonry.
I have tried to wait for the images to load, http://masonry.desandro.com/demos/images.html. I have tried reload once each image has been added - http://masonry.desandro.com/docs/methods.html#reload
None of which are working.
Here is my code, I'm not sure where I am going wrong.
$('.content').masonry();
var elements = '';
$.ajax({
type: "GET",
url: "/galleries/_archive/PhotoGallery.xml", // replace with absolute URL of your gallery's xml file
dataType: "xml",
success: function(xml) {
jQuery(xml).find('img').each(function(i) {
var location = "/galleries/_archive/"; // replace with absolute path to the directory that holds your images
var url = jQuery(this).attr('src');
var alt = jQuery(this).attr('alt');
elements+= '<div class="image-div"><img class="round'+i+'" src="'+location+''+url+'" alt="'+alt+'"/></div>';
});
$('.content').append(elements).shuffle().masonry('reload');
//$(".content .image-div").shuffle();
}
});
I have looked at this - jquery, masonry after append complete and this jQuery Masonry and Ajax Append Items?
I'm just wondering if on reload should the plugin wait for images to load? If so what is the syntax for this?
I also plan to hide the blocks (visibility:hidden), shuffle them into a random order and then masonry them then fade them in.
Any help would be amazing, I'm stumped. Thanks very much