ImagesLoaded with Masonry, Object #<Object> has no method 'imagesLoaded'

萝らか妹 提交于 2019-12-01 15:57:53

问题


Getting this error, trying to use Masonry with imageLoaded:

"Object # has no method 'imagesLoaded'"

The links to the necessary scripts are in my header:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script><script src="/js/masonry.pkgd.min.js" type="text/javascript"></script>
<script src="/js/imagesloaded.pkgd.min.js" type="text/javascript"></script>

And here is how the code looks in my footer:

$(document).ready(function() {
    $('#archive-post-container').imagesLoaded(function() {
        $(this).masonry({
            itemSelector : '.post',
            columnWidth:344
        });
    });
});

EDIT / ADDENDUM: Placing the script tags for ImagesLoaded and Masonry in the actual .php file for the page I need them on, instead of in header.php gets me this error instead, coming from ImagesLoaded: Uncaught TypeError: undefined is not a function

Not sure why moving the tags just from the to just under the header would change this, but at least now I am getting to imagesLoaded?


回答1:


Note that ImagesLoaded is no longer included in the latest Masonry distribution, per

http://masonry.desandro.com/appendix.html#upgrading-from-v2

You can get it directly here:

http://desandro.github.io/imagesloaded/



来源:https://stackoverflow.com/questions/17810400/imagesloaded-with-masonry-object-object-has-no-method-imagesloaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!