miromannino / Justified-Gallery

Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
http://miromannino.github.io/Justified-Gallery/
MIT License
1.68k stars 299 forks source link

Not being able to destroy the gallery instance on clicking a button. It shows error "Cannot read property 'css' of null". #251

Closed bluerid closed 5 years ago

bluerid commented 6 years ago

While trying to use the plugin I used the destroy method. It works for the first element and then breaks leaving the consequent images without changing the css attributes.

    jquery.justifiedGallery.min.js?ver=v3.6.3:7 Uncaught TypeError: Cannot read property 'css' of null
    at c.<anonymous> (jquery.justifiedGallery.min.js?ver=v3.6.3:7)
    at HTMLDivElement.d (jquery.js?ver=1.12.4:2)
    at Function.each (jquery.js?ver=1.12.4:2)
    at c.destroy (jquery.justifiedGallery.min.js?ver=v3.6.3:7)
    at HTMLDivElement.<anonymous> (jquery.justifiedGallery.min.js?ver=v3.6.3:7)
    at Function.each (jquery.js?ver=1.12.4:2)
    at a.fn.init.each (jquery.js?ver=1.12.4:2)
    at a.fn.init.a.fn.justifiedGallery (jquery.justifiedGallery.min.js?ver=v3.6.3:7)
    at HTMLElement.<anonymous> (ze-vc-gallery-masonry.js?ver=1.0.0:32)
    at HTMLElement.dispatch (jquery.js?ver=1.12.4:3)

This is how it looks.. screen

This is the code I have used to destroy the instance of each gallery on click..

$('.gallery-list').click(function(){
    $(this).parents('.gallery-wrapper')
        .find('.masonary-grid')
        .justifiedGallery('destroy');
  });
biziclop commented 6 years ago

.find('.masonary-grid') mason_A_ry?

bluerid commented 6 years ago

It is just the class selector. It should be masonry though, but I have got the selector wrong throughout. It works with the selector though. Only destroy is not working.