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 9098869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:28:09+00:00 2026-06-17T00:28:09+00:00

I have been able to append items to jQuery masonry quite happily in order

  • 0

I have been able to append items to jQuery masonry quite happily in order to create an “infinite scroll” affect.

I naively thought similar strategies would work for adding content before the Masonified content.

I setup masonry like this:

$(document).ready(function(){

   var $container = $('#pics');
        $container.imagesLoaded( 
        function(){
            $container.masonry({ 
            itemSelector : '.item',
            isFitWidth: true,
            isAnimated: true });
        });
});

The original images appear within this loop (using Playframework 1.2.4 with Java)

<div id="pics" class="pics">
            #{list items:pics, as:'pic'}
                <div class="item">
                    <a href="https://s3.amazonaws.com/bucket/${pic.url}"/>
                    <img src="https://s3.amazonaws.com/bucket/${pic.url}" class="pic" style="height:${pic.height}">
                    </a>
                </div>
            #{/list}
</div>

And this is where I am adding the new pictures into the Masonified “newpics” div:

  $.each(data.files, function (index, file) {

var filename_leaf = milliTime+"-"+file.name;
var filename_stem = "https://s3.amazonaws.com/bucket/";
var filename = filename_stem+filename_leaf;

var newpic = "<div class='item'>"+
   "<a href='"+filename+"'>"+
   "<img src='"+filename+"'"+
   " class='pic' style='height:"+file.height+"'>"+
   "</a></div>";

$('#pics').prepend(newpic).masonry('reload');

 });

What happens is that the pictures are prepended, however they fall behind the existing pictures.

If there was someway of refreshing/reloading the #pics div without refreshing the whole page that would pretty much solve the problem. I’m going to keep looking, but I suspect that someone else may know a better way.

  • 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-17T00:28:10+00:00Added an answer on June 17, 2026 at 12:28 am

    Your problem isn’t with Masonry. Your bug is that once the new photo is uploaded, the height value is undefined. This means that your picture markup look like this:

    <img style="height:undefined" class="pic" src="/photo.jpg">
    

    This causes problems because until getting the image, most browsers will render the picture as being height: 0. And this is what making the reload of the masonry mosaic “buggy” (it relayout the mosaic considering the first new image as being 0px in height).

    So, you should make sure you got a valid value for the height of the image. Or wait until the image is fully loaded to trigger the reload method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching for quite a while but I haven't been able to
I have been able to run my C# .net 3.5 app just fine on
I have been able to make my photos large for single photo posts on
I have been able to find lots of examples of adding a Dropdown list
I have been able to design my layout so that it has 2 columns
I have been able to set up OBDC in Filemaker, and added table ,
I have been trying different things and still have been able to get exactly
Hi I have been able to extract a VARCHAR to a date using string_to_date
What I have been able to grasp from reading the source and documentation from
I have this excel file which I have been able to write the data

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.