angular-masonry icon indicating copy to clipboard operation
angular-masonry copied to clipboard

Error: cannot call methods on masonry prior to initialization; attempted to call 'resize'

Open cristiandreica opened this issue 9 years ago • 4 comments

I have multiple pages (views) where I use masonry. At random moments (but pretty often), when I go from page 1 to page 2, then back to page 1, the masonry-bricks appear overlapped and I get this in the console:

cannot call methods on masonry prior to initialization; attempted to call 'resize'
cannot call methods on masonry prior to initialization; attempted to call 'appended'

I load the products array through ajax in a controller. Here's the code with the usage of masonry:

<div id="curated-products" masonry="{gutter: '.gutter-sizer', transitionDuration:'0', isFitWidth: true}" style="margin-left:auto; margin-right: auto" ng-cloak>
    <div class="gutter-sizer" style="width: 10px"></div>
    <div class="masonry-brick li-card" ng-repeat="product in products">
        <div class="li-product-cover">
            <a href="{{ product.productUrl }}">
                <img ng-src="{{ product.imageUrl }}" alt="{{ product.name }}" style="width:100%;">
            </a>
        </div>
        <a href="{{ product.productUrl }}" class="li-product-name">{{ product.name }}</a>
    </div>
</div>

I must be doing something wrong, as I saw this issue being closed before.

cristiandreica avatar Nov 23 '15 11:11 cristiandreica

Apparently, removing ng-cloak makes the bricks overlap a lot less often, but the two errors still appear. Does anyone have an idea why?

cristiandreica avatar Nov 27 '15 15:11 cristiandreica

+1, got the same problem

JohnnyTheTank avatar Nov 29 '15 23:11 JohnnyTheTank

Hey guys, any idea about this? :D

cristiandreica avatar Jan 08 '16 11:01 cristiandreica

I found out a bit more about this error. It is generated by jquery-bridget when masonry methods are being called without the namespace being initialised.

I am also not running on the latest release (currently 0.11.0), so I will fill in more information after I make the migration of the other dependencies.

cristiandreica avatar Feb 10 '16 22:02 cristiandreica