最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - no such method 'reload' for masonry instance - Stack Overflow

programmeradmin2浏览0评论

Good staff is as follows, when the page finishes loading, masonry failure and I do not know why, but I found a method that is masonry.reload.

This method works sometimes, I wonder why.

var $container = $('.container');
$container.masonry({    
        itemSelector: '.item',
        columnWidth: 25

}).imagesLoaded(function(){
    $container.masonry('reload');   
});

Good staff is as follows, when the page finishes loading, masonry failure and I do not know why, but I found a method that is masonry.reload.

This method works sometimes, I wonder why.

var $container = $('.container');
$container.masonry({    
        itemSelector: '.item',
        columnWidth: 25

}).imagesLoaded(function(){
    $container.masonry('reload');   
});
Share Improve this question asked Feb 5, 2014 at 0:47 Silvio LuisSilvio Luis 1931 gold badge3 silver badges11 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 16

In the newer versions of masonry you use "reloadItems" instead of "reload". I ran across a tip on this thread that pointed me in the right direction.

.imagesLoaded(function(){
      $container.masonry('reloadItems');   
      $container.masonry('layout');
});

Try the following:

<script src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>

var $grids = $('.masonrow').masonry({
    itemSelector : '.masonryme' 
});

$("#Box").append(e).imagesLoaded(function() {
    $grids.masonry('reloadItems');   
    $grids.masonry('layout');
});

i have same problem with you

yesterday i downloaded masonry from it's github repository, and masonry('reload') methods works, but now i change script source to cdn and it's not working anymore, maybe because different versions, after some googling, i got this http://masonry.desandro.com/methods.html#reloaditems, .masonry('reloadItems') to recollect all items element

发布评论

评论列表(0)

  1. 暂无评论