dsmorse / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://dsmorse.github.io/gridster.js/
MIT License
795 stars 194 forks source link

gm[1] is undefined when using "auto" base dimension #85

Open CaptainHypertext opened 7 years ago

CaptainHypertext commented 7 years ago

I tried using auto as the widget_base_dimension width as seen in this demo, but it gives me the error gm[1] is undefined. The stack trace points to this line in fn.get_highest_occupied_cell:

var gm = this.gridmap;
var rl = gm[1].length;

And gm is an empty array. Here is my full initialization:

grid.gridster({
        resize: {
            enabled: true,
            max_size: [10, 10],
            min_size: [3, 1],
            min_cols: 1,
            max_cols: 12,
        },
        widget_margins: [10, 10],
        widget_base_dimensions: ['auto', 140]
    })

It works fine if I take out the auto option. Am I doing this wrong, or is it a bug?

ayush-srtv commented 7 years ago

i am facing the same issue, waiting for any fixes.

pandaglasses commented 7 years ago

I ran into the same issue. I played around a lot with it until I found out adding the "max_cols" to the gridster options object itself seem to solve the problem (Note: CaptainHypertext's config seems to have the max_cols inside the resize object).

My object: gridster = $(".gridster ul").gridster({ widget_margins: [5, 5], widget_base_dimensions: ['auto', 100], autogenerate_stylesheet: true, min_cols: 4, max_cols: 4, min_rows: 7, resize: { enabled: true } }).data('gridster');