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

Cant make it work #323

Closed aero77 closed 4 years ago

aero77 commented 4 years ago

I have the following but it wont work.

In the header

`<link rel="stylesheet" href="js/css/justifiedGallery.css" />
<script src="js/jquery.justifiedGallery.js"></script>
<script type="application/javascript">

$('#colorboxExample').justifiedGallery({
    lastRow : 'nojustify', 
    rowHeight : 100, 
    rel : 'gallery1', //replace with 'gallery1' the rel attribute of each link
    margins : 1
}).on('jg.complete', function () {
    $(this).find('a').colorbox({
        maxWidth : '80%',
        maxHeight : '80%',
        opacity : 0.8,
        transition : 'elastic',
        current : ''
    });
});

</script>`

Unable to post my html but its a div tag with the ID colorboxExample with a link with the IMG tag

Sija commented 4 years ago

Of course it doesn't work, since it's in the <head>. To make it work you need to either, put it just before the </body> tag, or wrap it with $(document).ready(function() { ... })