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

Element Identification #252

Open CFPro opened 10 years ago

CFPro commented 10 years ago

I am trying to update my database with the new location of each element on the page. The serialization function is helpful in that, but I need to know how to add an identifier to each element, so when serialization happens I know which element is which. Any way to do that?

Thanks in advance!

CFPro commented 10 years ago

Never mind figured it out... I went into the source (jquery.gridster.js) and added this to the $w var

'data-identifier' : identifier (around line 956)

I also had to add

identifier: wgd.identifier (around line 748) wgd.identifier = new_wgd.identifier; (around line 1137) 'data-identifier': new_wgd.identifier (around line 1155) 'identifier': parseInt($el.attr('data-identifier'), 10) || false, (around line 1406) 'identifier': wgd.identifier (around 1421)

In the HTML, I added this parameter

  • data-identifier has to be an integer.
  • matthiasfeist commented 10 years ago

    I think this would be nice to have as an official feature in Gridster. An id of the widget which is written to the serialised data and then when loading a grid from this data also re-applied onto the corresponding widget.

    That is also a major issue mentioned in this blog-post: https://blog.serverdensity.com/using-gridster-to-build-custom-dashboards