Giter Site home page Giter Site logo

Comments (5)

mellson avatar mellson commented on August 24, 2024

Fixed this with a helper method that sorts the returned array based on row / col

from gridster.js.

jameskenny avatar jameskenny commented on August 24, 2024

Is there a way I can get the Element Id with serialize?

from gridster.js.

jameskenny avatar jameskenny commented on August 24, 2024

nvm,

function testing(){
var pos = 1;
var ids = $("#dash li")
.map(function () {
return this.id;
}).get();

$.each(
    ids,
    function(){
        //alert(this);
        var col = $("#"+this).attr("data-col");
        var row = $("#"+this).attr("data-row");
        var y = $("#"+this).attr("data-sizey");
        var x = $("#"+this).attr("data-sizex");
        var id = this.replace("id_","");
        alert(id+"="+col+"="+row+"="+y+"="+x+"="+pos);
        pos++;
    }
);

}

from gridster.js.

kayrules avatar kayrules commented on August 24, 2024

Try this to get serialize data for id, row & column for the current order:

var gridster = $(".gridster ul").gridster({
        widget_margins: [10, 10],
        widget_base_dimensions: [140, 140],
        serialize_params: function($w, wgd) {
            return {
                id: wgd.el[0].id,
                col: wgd.col,
                row: wgd.row
            };
        }
    }).data('gridster');

    $('#check').bind('click',function() {
        console.log(gridster.serialize());
        return false;
    })

from gridster.js.

Wttewaall avatar Wttewaall commented on August 24, 2024

Thanks to @kayrules I wrote a serialize method that also calculates the order:

var contentGrid = $(".gridster ul").gridster({
    widget_margins: [5, 5],
    widget_base_dimensions: [178, 143],
    min_cols: 3, max_cols: 3,

    // custom serialization method that also returns the order index
    serialize_params: function($w, wgd) {
        return {
            id: $w.data('id'),
            row: wgd.row,
            col: wgd.col,
            order: (wgd.row - 1) * contentGrid.cols + (wgd.col - 1),
            element: $w
        };
    },

    draggable: {
        stop: function() {
            updateContentOrder(contentGrid.serialize());
        }
    }

}).data('gridster');

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.