当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - JQuery Masonry not displaying correctly when loading external page

问题描述:

So I'm having trouble with Masonry not properly displaying images when I load a page with JQuery into the container div. I'm trying to prevent the page from refreshing for each section. The initial loading of the page works fine, but once I load a page into the div it breaks. Here is my code.

$('#container').load("photos.php?directory="+str, function () {

var container = $('#container');

container.imagesLoaded( function() {

container.masonry();

});

});

I'm even trying to reload Masonry after the images fully load in the div(I don't mind not having to do that). Any help would be greatly appreciated!

网友答案:

Fixed the issue. I had to load the options in JQuery instead of HTML.

$('#container').load("photos.php?directory="+str, function () { var container = $('#container'); container.masonry('reloadItems'); $('#container').masonry({ columnWidth: 156, itemSelector: '.item' }); });

分享给朋友:
您可能感兴趣的文章:
随机阅读: