ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.03k stars 1.2k forks source link

Grid elements not re positioning when building the grid #521

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi everyone, I'm aiming to have a "responsive" grid and only allow the number of columns that fit on the screen, avoiding horizontal scroll. Gridster does this already, but if If an element has the data-col=8 and my screen only allows 5, it will be on the 8th with horizontal scroll on the page.

The list of elements if generated server side and placed inside the grid container, then, the script starts the grid and the elements are placed outside my my 5 col grid.

However, If I add the widgets dynamically using add_widget(), they are re positioned to fill the 5 cols and the data-col=8 is replaced by the col where it was placed.

The question is, how can I have the behavior of the add_widget but with my elements already in the container?

p.s. What does the helper option do? I cant find any documentation on it. (this is probably a dumb one)

ghost commented 9 years ago

Worked with add_widget and also replacing the data attributes before calling the init() function, at least the grid is now responsive, even with saved data that didn't fit the screen.