Giter Site home page Giter Site logo

Comments (2)

carlhussey avatar carlhussey commented on July 18, 2024

@dsmorse - Is there any method built in that I can call once items have been dynamically added to the DOM for it to know there the items are since they are not added with the "Add" method? I assume there is an underlying grid of available spots and what not and these aren't updated when the plugins are loaded directly into the DOM.

from gridster.js.

hellhoundsx avatar hellhoundsx commented on July 18, 2024

I know I'm a bit late to this, but I was having the same problem. So what I did was that I ordered the items before I started adding them to gridster.
The problem is that gridster isn't obeying to the position of certain elements, like if the first one in the array is positioned at the "row 5, col 1", it gets rendered first and it will go to "row 1, col 1" for some reason.

So what I do is the following:

exampleArray.sort(function (a, b) {
    var aRow = a.layout.row;
    var bRow = b.layout.row;
    var aCol = a.layout.col;
    var bCol = b.layout.col;

    if (aRow == bRow) {
        return (aCol < bCol) ? -1 : (aCol > bCol) ? 1 : 0;
    } else {
        return (aRow < bRow) ? -1 : 1;
    }
});

This will return you guys your array ordered per row and column and Gridster will be able to render them correctly.

from gridster.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.