Troubleshooting problems with Isotope jQuery plugin's layout

Setting up Isotope on this website is proving to be a bit tricky. It's supposed to handle the layout and allow me to append items to the container.

The problem lies in the fact that the images don't seem to initialize properly. Here's how I've initialized it:

$(document).ready(function(){

    var $container = $('#container');
    $container.isotope({
          masonry: {
            columnWidth: 400,
            gutterWidth: 10
        },
        filter: '*',
        animationOptions: {
            duration: 750,
            easing: 'linear',
            queue: true
        },
        resizesContainer: true,
    });

    load_more();
});

The images aren't affected by the masonry options, and specifying "width" in the CSS causes loading issues.

The load_more function makes an ajax call and upon success, calls this function with the returned data:

function data_loaded(data) {

    var newItems = "";
    for (var i = 0; i < data['posts'].length; i++) {
        newItems += '<div class="item" ><img class="gallery_img" src="'+data['posts'][i]['images'][0]['path']+'" /></div>';
    }

    /* append images*/
    var $newItemsObj = $(newItems);
    $('#container').isotope( 'insert', $newItemsObj );
}

The website can be found at It's safe for work, no nude images

It seems like the site needs a refresh to load properly. Perhaps the images are cached the second time around, causing the initial failure due to triggering Isotope before image loading?

Answer №1

Isotope may not function properly as the dimensions of your images are currently 0 since they haven't loaded yet. You can resolve this issue by utilizing https://github.com/desandro/imagesloaded or setting the height and width of your images using CSS.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

exploring the mysql database using node.js

I am currently working on a Discord bot and I'm in need of some assistance with the code snippet. Specifically, I am trying to implement a function that checks if the nickname of the user who triggered a command matches any nicknames stored in the "pl ...

Syntax error: The term 'yield' is restricted

In my current project, I am utilizing typescript along with gulp for compilation tasks. Below is the gulp task that I have set up for compiling my typescript code: gulp.task('compile', function () { return gulp.src('src/**/**/*.*' ...

JQuery post request not providing the expected response after posting

I have a post request var prodId = getParameterByName('param'); var pass = $('#password1').val(); $.post("rest/forget/confirm", { "param" : prodId, "password" : pass }, function(data) { ...

Issue between Promise and EventEmitter causing race conditions in ExpressJS

Currently, I am working on a NodeJS/Express web application where users can upload files that are then parsed using the connect-busboy module and saved to a database with Sequelize. Once the data is stored, I aim to redirect the user to a specific page. Ho ...

Why is my jQuery $.ajax success function not providing any results?

When checking the Network tab in Chrome, I noticed that the correct data (action, username, password) is being sent, but the message is not returning to $('#return_login'). Can anyone spot what might be wrong with my code? Below is the jQuery co ...

Typescript does not allow for extending an interface with a data property even if both interfaces have the same data type

I've encountered a peculiar problem with Typescript (using Visual Studio 2012 and TypeScript v0.9.5) that I could use some help clarifying. The code snippet below functions correctly: interface IA { data: any; } interface IB { data: any; } ...

Ways to change babel transpiled code back into regular JavaScript

I have been utilizing a plugin known as babel-plugin-transform-react-class-to-function to convert React classes into functional components. While the plugin successfully transpiles the input code, I actually need the original plain code as outlined in the ...

Bootstrap justify-content-around is not evenly distributing items

I am attempting to evenly distribute three rows of four bootstrap cards across a jumbotron with space-around, but it is not displaying correctly. I suspect there may be a margin interference issue that is included with Bootstrap. Here is the code I am usin ...

Verifying updates in the watchlist once data has been initialized upon mounting

When trying to edit a component, the data is loaded with mounted in the following way: mounted () { var sectionKey = this.$store.getters.getCurrentEditionKey this.table = _.clone(this.$store.getters.getDocumentAttributes[sectionKey]) this.ta ...

Angular $watch fails to fire upon modification of $scope variable

At the start of my application, I need to execute a routine using user data that is fetched during initialization. In the controller for the homepage, I check if there is a token stored (indicating a logged-in user) and then proceed to run the routine if ...

Is it possible to integrate a Twitter bootstrap theme into a Rails 4 application if the Vendor/assets directory is missing?

My goal is to integrate a theme from wrapbootstrap.com into my rails 4.1 application. After creating a new app with rails 4 scaffolding, I proceeded to extract the downloaded zip directory which contains 4 directories and an index.html file. I then placed ...

Tips and tricks for personalizing the leaflet Lopup component using vue js

Seeking guidance on customizing the design of the LPopup component in leafletjs. I found a helpful guide at: https://i.sstatic.net/qEZol.png After inspecting the Lpopup in the dev tools, I tried adding CSS styles to the 'leaflet-popup-content-wrappe ...

"Learn the technique of displaying or concealing a row in a ListView with the help of

I'm currently utilizing an Asp.net Listview for displaying data in a "grid" format. Below is the code snippet: <asp:ListView ID="lvDmr" runat="server" DataSourceID="dsDmr" DataKeyNames="id"> <ItemTemplate> &l ...

Save the contents of a file within an HTML table using jQuery

I needed to insert multiple files into the database by uploading and adding each file's content to a table. Once all files were added to the table, I included the table's values along with the file content in form data which was then passed to aj ...

Generating forms dynamically using JSON data

Currently, I'm using three nested ng-repeat directives to display multiple questions and their corresponding answers. Everything is displaying correctly so far, but now I need to create a form to save the answers. What would be the best approach to ac ...

Which method proves to be more effective - making an ajax call to the server or iterating through the data array?

I am faced with a dilemma regarding an array of data. Let's call it var products =[]; this array will consist of 10000 elements. My task is to identify all the products that have the name item1. Which method would be more efficient in terms of perform ...

What aspects of MongoDB security am I overlooking?

Is it a secure way to connect to Mongo DB by using Node JS, Mongo DB, and Express? Could someone provide an explanation of this code in terms of security? === Many tutorials often only show... var mongoClient = new MongoClient(new Server('localhos ...

Working with time durations in JavaScript

Is there a way to calculate the duration between a start time and an end time including both hours and minutes? Currently, I have code that only provides me with the hours. Is there any modification I can make to include minutes as well? If so, what chan ...

I'm looking for a simple calendar widget that can be clicked on using only plain JavaScript/jQuery and is compatible with Bootstrap

I'm in search of a simple clickable calendar widget to integrate into my website. I am using a combination of HTML, CSS, Bootstrap 5, and jQuery 3.6 for development. The functionality I require is for the calendar days to be clickable so that I can di ...

Unable to adjust SVG fill color

I'm having trouble changing the fill color of an SVG when the user hovers over it. Can someone help me figure out why my code isn't working? svg:hover { fill: blue; } <svg width="0" height="0" class="hidden"> <symbol viewBox="0 0 ...