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

Retrieving the saved state #202

Closed nagkumar91 closed 10 years ago

nagkumar91 commented 11 years ago

Hey, I saw the previous issues which told me about "serialize". I have to maintain the order of the re-positioned widgets whenever the page is refreshed. Is there any way to dynamically assign the row and col values?

I am logging the state like this: gridster = $(".gridster ul").gridster({ serialize_params: function($w, wgd) { return { id: wgd.el[0].id, col: wgd.col, row: wgd.row, size_x: wgd.size_x, size_y: wgd.size_y, widget_margins: [25, 25], widget_base_dimensions: [350, 150], min_cols: 3, } }, draggable: { stop: function(event, ui) { var positions = JSON.stringify(gridster.serialize()); console.log(positions); } } }).data('gridster'); Please help!

vieron commented 10 years ago

See here how to build a grid from a previously serialized object.