germanysbestkeptsecret / Wookmark-jQuery

A jQuery plugin to create a dynamic, multi-column layout.
MIT License
2.63k stars 759 forks source link

Endless scrolling with colorbox issue #136

Closed modastic closed 10 years ago

modastic commented 10 years ago

I have both endless scrolling and lightbox setup and working fine independently. However, after opening and closing lightbox, the endless scrolling stops working. I get this error when re-applying the layout after loading new data:

Uncaught TypeError: Object [object Object] has no method 'wookmark' 

I initiate lightbox using the code below:

    $('a', handler).colorbox({
      rel: 'nofollow',
      opacity: 0.7,
      width: "880px",
      height: "700px",
      scrolling: false,
      returnFocus: false,
    });

Once new data has been loaded via AJAX after scrolling, and appended to the container, this code updates the layout:

function applyLayout() {
    options.container.imagesLoaded(function() {
        // Create a new layout handler when images have loaded.
        handler = $('.tiles');
        handler.wookmark(options); // This line throws exception

        // Init lightbox
        $('a', handler).colorbox({
          rel: 'nofollow',
          opacity: 0.7,
          width: "880px",
          height: "700px",
          scrolling: false,
          returnFocus: false,
        });
    });
};

I logged handler to the console and it looks fine.

[div#tile-first.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, div.tiles, prevObject: x.fn.x.init[1], context: document, selector: ".tiles", jquery: "1.10.2", constructor: function…]

Just to clarify, the endless scrolling works perfectly when I don't click on anything and open lightboxes.

Anyone know what I'm doing wrong here?

Thanks,

Sebobo commented 10 years ago

Hi,

you should remove the old handler before reapplying it like in the original endless scroll example. I can't really say why the error is thrown. If you provide an example on your server or another link, I could provide further help.

Regards

modastic commented 10 years ago

Here's a link to it on my server:

Please take a look, You can see that if you click and open a lightbox, the endless scrolling stops working. My code is in test.js

Thanks for the help.

modastic commented 10 years ago

Nevermind, I found the problem, the page opened by colorbox was including jQuery a second time which caused the plug-in to stop working.

Thanks and great library btw