Masonry Image gallery not working, inline Javascript not taking any effect

Luke

I just included Masonry Lib into my wordpress site to display an image gallery: http://letpack.lukasoppler.ch/geschuetzte-arbeitsplaetze/gebaeudeunterhalt/

I am calling masonry throug html markup in the div-Element, it is looking like this:

<div class="grid" data-masonry="{ " itemSelector" ".grid-item" }">
    <div class="grid-item">
        <img src="image-url" width="700" height="470">
    </div>
    <div class="grid-item">
        <img src="image-url" width="700" height="470">
    </div>
    <div class="grid-item">
        <img src="image-url" width="700" height="470">
    </div>
</div>

etc...

CSS Style is looking like:

.grid-item > img {
    height: auto;
}
.grid-item {
  float: left;
  padding: 0 10px 10px 0;
  width: 50%;
}

My first problem is that the following code which is in the header is not working, so I am not able to use imageloaded lib to prevent images to overlap when they are not cached. When i remove the html json code masonry is not working at all.

<script type="text/javascript" language="javascript">
    // external js: masonry.pkgd.js, imagesloaded.pkgd.js

    // init Masonry after all images have loaded
    var $grid = $('.grid').imagesLoaded(function () {
        $grid.masonry({
            itemSelector: '.grid-item',
            percentPosition: true,
            columnWidth: '.grid-sizer'
        });
    });
</script>

Masonry + Image Loaded is included in the header section.

But neither the java script to call masonry nor the imageloaded lib make any effect.

Can you help me analyzing my problem?

Luke

Serg Chernata

You are calling imagesLoaded before that lib has actually been loaded. Wrap it into document.ready callback.

<script type="text/javascript" language="javascript">
    $(function() {
        // external js: masonry.pkgd.js, imagesloaded.pkgd.js

        // init Masonry after all images have loaded
        var $grid = $('.grid').imagesLoaded(function () {
            $grid.masonry({
                itemSelector: '.grid-item',
                percentPosition: true,
                columnWidth: '.grid-sizer'
            });
        });
    });
</script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Responsive image gallery using Masonry

From Dev

Responsive image gallery using Masonry

From Dev

Magnific popup fade effect on inline gallery mode

From Dev

Javascript function as argument not taking effect

From Dev

Image gallery album cover effect in android

From Dev

How to Add AutoSlide effect to a specific image gallery?

From Dev

Full width gallery with Masonry

From Dev

Delete of image not working in code igniter image gallery

From Dev

JavaScript code for my Image Gallery

From Dev

Javascript splice for filtering image gallery

From Dev

Loading Image Gallery taking too time in Razor View

From Dev

Code to set any image as a wallpaper from the gallery

From Dev

JavaScript Inline Validation not Working

From Dev

My JavaScript image gallery slider's right slider isn't working and my left one is

From Dev

Jquery next button not working with image gallery

From Dev

Popover image gallery not working in iPad iOS Swift

From Dev

Phonegap image picker from gallery not working properly

From Dev

JavaScript and Bootstrap image gallery with different image sizes

From Dev

Javascript : gauge image effect

From Dev

mailgun send inline image not working?

From Dev

mailgun send inline image not working?

From Dev

taking a photo and placing it in the Gallery

From Dev

Pure javascript image gallery with fwd and bck function

From Dev

How to filter image gallery by tags using Javascript?

From Dev

basic javascript image gallery logic error?

From Dev

How to create a mini image gallery using javascript?

From Dev

Working on Creating Image Gallery in JavaFX. not able to display image properly

From Dev

Inline Javascript NOT Rails Heroku not working

From Dev

Setting Inline Styles with JavaScript Not Working

Related Related

  1. 1

    Responsive image gallery using Masonry

  2. 2

    Responsive image gallery using Masonry

  3. 3

    Magnific popup fade effect on inline gallery mode

  4. 4

    Javascript function as argument not taking effect

  5. 5

    Image gallery album cover effect in android

  6. 6

    How to Add AutoSlide effect to a specific image gallery?

  7. 7

    Full width gallery with Masonry

  8. 8

    Delete of image not working in code igniter image gallery

  9. 9

    JavaScript code for my Image Gallery

  10. 10

    Javascript splice for filtering image gallery

  11. 11

    Loading Image Gallery taking too time in Razor View

  12. 12

    Code to set any image as a wallpaper from the gallery

  13. 13

    JavaScript Inline Validation not Working

  14. 14

    My JavaScript image gallery slider's right slider isn't working and my left one is

  15. 15

    Jquery next button not working with image gallery

  16. 16

    Popover image gallery not working in iPad iOS Swift

  17. 17

    Phonegap image picker from gallery not working properly

  18. 18

    JavaScript and Bootstrap image gallery with different image sizes

  19. 19

    Javascript : gauge image effect

  20. 20

    mailgun send inline image not working?

  21. 21

    mailgun send inline image not working?

  22. 22

    taking a photo and placing it in the Gallery

  23. 23

    Pure javascript image gallery with fwd and bck function

  24. 24

    How to filter image gallery by tags using Javascript?

  25. 25

    basic javascript image gallery logic error?

  26. 26

    How to create a mini image gallery using javascript?

  27. 27

    Working on Creating Image Gallery in JavaFX. not able to display image properly

  28. 28

    Inline Javascript NOT Rails Heroku not working

  29. 29

    Setting Inline Styles with JavaScript Not Working

HotTag

Archive