I'm using the jQuery plugin "Masonry" (http://masonry.desandro.com/) to sort some DIVs. These DIVs are loaded with AJAX and somehow, the plugin starts too early and get the positions wrong. How can I set a proper delay in these functions?
function loadALLtheposts(id) {
$.ajax({
url: "******.php",
data: {userID: id},
type: "POST",
dataType: "text",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function (data) {
$('#timeline-posts').html(data);
masonry_index();
}
});
}
function masonry_index() {
$('#timeline-posts').masonry({
itemSelector : '.post-wrapper',
columnWidth : 266
});
}
Thank you in advance.