First you will need a unique ID for each element
You can modify the params object stored for each element using the serialize_params
option of plugin
gridster = jQuery(".gridster > ul").gridster({
/* other options*/
serialize_params: function ($w, wgd) {
return {
/* add element ID to data*/
id: $w.attr('id'),
/* defaults */
col: wgd.col,
row: wgd.row,
size_x: wgd.size_x,
size_y: wgd.size_y
}
}
})
Then when you select an item can filter the gridster data array to locate the current ID. I'm using jQuery.grep()
in this example
jQuery('.gridster ul li').click(function () {
var id=this.id;
var t = jQuery.grep(gridster.serialize(),function(item){
return item.id==id;
})
jQuery('#log_2').val(JSON.stringify(t));
})