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

Serialization with id of < li > ? #266

Open lgm42 opened 10 years ago

lgm42 commented 10 years ago

Is it possible to have the id of the < li > if given in serialization command ? It will be more easily to get div configuration. Because today, we must save the insertion order at the beginning and when I serialize, I must retreive my insertion list and the serialization result to save each widget configuration.

If I have < li id="widget0" data-row="1" data-col="1" data-sizex="2" data-sizey="2" >0< /li > It would be cool to have in result :

[{"id":"widget0","col":1,"row":1,"size_x":2,"size_y":2}]

smajl commented 10 years ago

Consider reading the API first next time.. You would find a http://gridster.net/#serialize_params_opt

In your case, you will use it like this:

element.gridster({
  ...
  serialize_params: function ($w, wgd) {
    return {
      id: $w.prop('id'),
      col: wgd.col,
      row: wgd.row,
      size_x: wgd.size_x,
      size_y: wgd.size_y,
    };
  },
  ...
});
lgm42 commented 10 years ago

Okay thank you I have seen this function but I haven"t understand its functionnality !

Thank you very much !