Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:03:01+00:00 2026-06-13T11:03:01+00:00

I adapted this script from the wookmark plugin to load more items from a

  • 0

I adapted this script from the wookmark plugin to load more items from a db when the users scrolls to the bottom of the page.

Initially it pre loads the images and then creates the layout, however when the users scrolls to the bottom, the new items are loaded thru ajax but the images all overlap each other.

I’m using the imagesloaded jquery plugin to get the images to display correctly when the page loads the first time but i cant get it to work when new items are added when the users scrolls to the bottom.

here’s my code:

  $(document).imagesLoaded(function() {
     $(document).ready(new function() {

       // Prepare layout options.
       var options = {
         autoResize: true, // This will auto-update the layout when the browser window is resized.
         container: $('#main'), // Optional, used for some extra CSS styling
         offset: 10, // Optional, the distance between grid items
         itemWidth: 320 // Optional, the width of a grid item
       };

       // Get a reference to your grid items.
       var handler = $('#tiles li');

       // Call the layout function.
       handler.wookmark(options);


       // When scrolled all the way to the bottom, add more tiles.
        var int = 10;

        function onScroll(event) {
          // Check if we're within 100 pixels of the bottom edge of the broser window.
          var closeToBottom = ($(window).scrollTop() + $(window).height() > $(document).height() - 100);

          if(closeToBottom) {

             // GET THE 10 NEXT ITEMS;
              if (window.XMLHttpRequest)
                 {// code for IE7+, Firefox, Chrome, Opera, Safari
                 xmlhttp=new XMLHttpRequest();
                 }
               else
                 {// code for IE6, IE5
                 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                 }
               xmlhttp.onreadystatechange=function()
                 {
                 if (xmlhttp.readyState==4 && xmlhttp.status==200)
                   {
                   //document.getElementById("tiles").innerHTML=xmlhttp.responseText;



                         $('#tiles').append(innerHTML=xmlhttp.responseText);
                         int = int+10;
                         // Clear our previous layout handler.
                         if(handler) handler.wookmarkClear();

                         // Create a new layout handler.
                         handler = $('#tiles li');
                         handler.wookmark(options);

                   }
                 }

               $.extend({
                    getUrlVars: function(){
                      var vars = [], hash;
                      var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                      for(var i = 0; i < hashes.length; i++)
                      {
                        hash = hashes[i].split('=');
                        vars.push(hash[0]);
                        vars[hash[0]] = hash[1];
                      }
                      return vars;
                    },
                    getUrlVar: function(name){
                      return $.getUrlVars()[name];
                    }
                  });

                  var request = $.getUrlVar('item');

                  if(request!=null){
                    var allR = "?int="+int+"&item="+request;
                  } else {
                    var allR = "?int="+int;
                  }

               xmlhttp.open("GET","tiles.php"+allR,true);
               xmlhttp.send();
          }
        };

        $(document).ready(new function() {
          // Capture scroll event.
          $(document).bind('scroll', onScroll);

          // Call the layout function.
          handler = $('#tiles li');
          handler.wookmark(options);
        });      
     });  
   });  

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:03:02+00:00Added an answer on June 13, 2026 at 11:03 am

    In the end i forgot to try the simplest thing, wrap the handler.wookmark in imagesLoaded:
    $(document).imagesLoaded(function() {
    handler.wookmark(options);
    });

    Full code:

    $(document).imagesLoaded(function() {
         $(document).ready(new function() {
    
           // Prepare layout options.
           var options = {
             autoResize: true, // This will auto-update the layout when the browser window is resized.
             container: $('#main'), // Optional, used for some extra CSS styling
             offset: 10, // Optional, the distance between grid items
             itemWidth: 320 // Optional, the width of a grid item
           };
    
           // Get a reference to your grid items.
           var handler = $('#tiles li');
    
           // Call the layout function.
           handler.wookmark(options);
    
           // When scrolled all the way to the bottom, add more tiles.
            var int = 10;
    
            function onScroll(event) {
              // Check if we're within 100 pixels of the bottom edge of the broser window.
              var closeToBottom = ($(window).scrollTop() + $(window).height() >     $(document).height() - 100);
    
              if(closeToBottom) {
    
    
                 // GET THE 10 NEXT ITEMS;
                  if (window.XMLHttpRequest)
                     {// code for IE7+, Firefox, Chrome, Opera, Safari
                     xmlhttp=new XMLHttpRequest();
                     }
                   else
                     {// code for IE6, IE5
                     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                     }
                   xmlhttp.onreadystatechange=function()
                     {
                     if (xmlhttp.readyState==4 && xmlhttp.status==200)
                       {
                       //document.getElementById("tiles").innerHTML=xmlhttp.responseText;
    
    
                             $('#tiles').append(innerHTML=xmlhttp.responseText);
    
    
    
                             int = int+10;
                             // Clear our previous layout handler.
                             if(handler) handler.wookmarkClear();
    
                             // Create a new layout handler.
                             handler = $('#tiles li');
    
                             $(document).imagesLoaded(function() {
                             handler.wookmark(options);
                           });
    
    
    
                             $(function() {
                                // Select all links whose attribute rel starts with lightbox
                                $('a[rel^=lightbox]').lightBox();
                             });
    
                             var scripts = domElement.getElementsByTagName("script");
                               for (var i = 0; i < scripts; i ++) {
                                   eval(scripts[i].text);
                               }
    
    
    
                       }
    
    
    
                } 
                   $.extend({
                        getUrlVars: function(){
                          var vars = [], hash;
                          var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                          for(var i = 0; i < hashes.length; i++)
                          {
                            hash = hashes[i].split('=');
                            vars.push(hash[0]);
                            vars[hash[0]] = hash[1];
                          }
                          return vars;
                        },
                        getUrlVar: function(name){
                          return $.getUrlVars()[name];
                        }
                      });
    
                      var request = $.getUrlVar('item');
    
                      if(request!=null){
                        var allR = "?int="+int+"&item="+request;
                      } else {
                        var allR = "?int="+int;
                      }
    
    if(end==0){
                   xmlhttp.open("GET","tiles.php"+allR,true);
                   xmlhttp.send();
                 }
    
                 }
    
            };
    
            $(document).ready(new function() {
              // Capture scroll event.
              $(document).bind('scroll', onScroll);
    
              // Call the layout function.
              handler = $('#tiles li');
              handler.wookmark(options);
    
    
            });      
         });
    
       });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I copied this systemd service file from the lighttpd-package and adapted it to make
I have taken this code from somewhere and adapted it. I have managed to
I have a JavaScript-driven parallax slider, adapted from this tutorial ( http://tympanus.net/codrops/2011/01/03/parallax-slider/ ), and
I have the following script (adapted from here) for uploading files via ftp for
I adapted this solution into my script. The idea is to prevent the user
I have a Python script adapted from Downloading MMS emails sent to Gmail using
I have this code which I have found from google. It's a adapter for
I adapted the jQuery slider code from http://webdeveloperplus.com/jquery/featured-content-slider-using-jquery-ui/ into my website which is based
I have adapted some code from a great article I found about circle drawing
Using an adapted version of jquery.inplace.js for some page creation and use an OBDC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.