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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:07:49+00:00 2026-06-06T07:07:49+00:00

Good evening, I’m having an issue with Masonry. This is all my relevant code:

  • 0

Good evening,

I’m having an issue with Masonry.

This is all my relevant code:

var $test;
var $iterator = 0; 
$(document).ready(function() {
    $("#demo-input").tokenInput("php-example.php" ,{
        classes: {
            tokenList: "token-input-list-facebook",
            token: "token-input-token-facebook",
            tokenDelete: "token-input-delete-token-facebook",
            selectedToken: "token-input-selected-token-facebook",
            highlightedToken: "token-input-highlighted-token-facebook",
            dropdown: "token-input-dropdown-facebook",
            dropdownItem: "token-input-dropdown-item-facebook",
            dropdownItem2: "token-input-dropdown-item2-facebook",
            selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
            inputToken: "token-input-input-token-facebook"
        },
        hintText: "Type in the names of your Tags",
        noResultsText: "No results",
        searchingText: "Searching..."
    });
});

var $container = $('#container');

$container.imagesLoaded( function(){
    $container.masonry({
        itemSelector: '.box',
        columnWidth: 1,
        isAnimated: !Modernizr.csstransitions
    });
});

$(document).ready(function() {
    $("input[type=button]").click(function () {
        $.ajax({ url: "generatehtml.php",
        data: {action: $(this).siblings("input[type=text]").val()},
        type: 'post',
        dataType: "json",
        success: 
            function(response){
                $test=response;
                $iterator =  $test.length;

                for (i=0; i<10; i++){
                    var $boxes = $(balls($iterator));
                    $container.append( $boxes ).imagesLoaded( function(){$container.masonry( 'appended', $boxes);});            
                }
                var $boxes = $( '<div class="box" STYLE="color: rgba(255, 255, 255, 1);">These results are ranked from<BR> most similar, to least similar.<BR>The percentage below each game <BR>indicates how similar to the <BR>original input that game is.<BR></div>' );
                $container.prepend( $boxes ).masonry( 'reload' );       
            }
        });
    });
});


window.onscroll = scroll;

function scroll() {  
    var $boxes = $(balls($iterator));
    $container.append( $boxes ).imagesLoaded( function(){$container.masonry( 'appended', $boxes, true);});
}  
//+'<img src="timthumb.php?src='+$test[$iterator][2]+'&q=100&w=300"/>' Replace this with the one below when timthumb is whitelisted
function balls($i){
    $iterator -= 1;
    var $width = 7.5;
    return ('<div class="box">'
    +''+$test[$iterator][1][2]+''
    +'<img src="'+$test[$iterator][2]+'"  width="280" height="160"/>'
    +'<div id=boxBottom>'+Math.floor($test[$iterator][0]*100)+'%</div>'
    +'</div>');
}

The behaviour I expect:
Load page, select game from second search bar, hit ‘submit’.
Populate with 10 results, upon scrolling, populate with more results.

But the formatting is all over the place, and I know you’re supposed to use the imagesLoaded() plugin, but I do.

Anyway, here is the site in question:

http://newgameplus.nikuai.net/TEST/
(First search bar doesn’t work btw, so ignore that)

Any resolution would be greatly appreciated. Thanks so very much.

  • 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-06T07:07:50+00:00Added an answer on June 6, 2026 at 7:07 am

    Try changing your columnWidth to the same as the image in the box:

    $container.imagesLoaded( function(){
        $container.masonry({
            itemSelector: '.box',
            columnWidth: 280,
            isAnimated: !Modernizr.csstransitions
        });
    });
    

    Update the line:

    $container.append( $boxes ).imagesLoaded( function(){$container.masonry( 'appended', $boxes);});
    

    to:

    $container.append( $boxes ).masonry('appended', $boxes);
    

    I also think you should revise your $(document).ready sections. You currently have 2 of them and the #container element is retrieved between the two. I think you should only have the one and make sure the $container is fetched in the $(document).ready.

    Updated code:

    var $test;
    var $iterator = 0; 
    $(document).ready(function() {
        $("#demo-input").tokenInput("php-example.php" ,{
            classes: {
                tokenList: "token-input-list-facebook",
                token: "token-input-token-facebook",
                tokenDelete: "token-input-delete-token-facebook",
                selectedToken: "token-input-selected-token-facebook",
                highlightedToken: "token-input-highlighted-token-facebook",
                dropdown: "token-input-dropdown-facebook",
                dropdownItem: "token-input-dropdown-item-facebook",
                dropdownItem2: "token-input-dropdown-item2-facebook",
                selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
                inputToken: "token-input-input-token-facebook"
            },
            hintText: "Type in the names of your Tags",
            noResultsText: "No results",
            searchingText: "Searching..."
        });
    
        var $container = $('#container');
    
        $container.imagesLoaded( function(){
            $container.masonry({
                itemSelector: '.box',
                columnWidth: 280,
                isAnimated: !Modernizr.csstransitions
            });
        });
    
        $("input[type=button]").click(function () {
            $.ajax({ url: "generatehtml.php",
            data: {action: $(this).siblings("input[type=text]").val()},
            type: 'post',
            dataType: "json",
            success: 
                function(response){
                    $test=response;
                    $iterator =  $test.length;
    
                    for (i=0; i<10; i++){
                        var $boxes = $(balls($iterator));
                        $container.append( $boxes ).masonry('appended', $boxes);            
                    }
                    var $boxes = $( '<div class="box" STYLE="color: rgba(255, 255, 255, 1);">These results are ranked from<BR> most similar, to least similar.<BR>The percentage below each game <BR>indicates how similar to the <BR>original input that game is.<BR></div>' );
                    $container.prepend( $boxes ).masonry( 'reload' );       
                }
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening, I am having a weird issue with a method I am trying
Good evening :-)! I have this code to use Drag & Drop method for
Good evening. This code works. It sorts an array of cards by both Suit
Good Evening folks. This is my code: static private function removeAccentedLetters($input){ for ($i =
Good evening all, I've been working on an MD5 tool in C# that takes
Good evening. For a project, I have to create a system. In this system,
Good evening fellow coders, and thank you in advance for any help/attention. This is
Good Evening All, I've created the following stored procedure: CREATE PROCEDURE AddQuote -- Add
Good evening StackOverflow This time I'm fighting with a ListView Containing TextViews. I add
Good Evening All, A client has asked that I develop a web application as

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.