no such method 'reload' for masonry instance
Asked Answered
S

3

7

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');   
});
Sundog answered 5/2, 2014 at 0:47 Comment(0)
V
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');
});
Venal answered 3/8, 2014 at 4:38 Comment(1)
yes, it's worked for my react components to , thank you very much.Inamorata
R
2

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');
});
Raybourne answered 30/3, 2018 at 9:40 Comment(0)
C
0

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

Chang answered 2/3, 2014 at 6:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.