I've been using Gridstack for dynamically creating a grid. I have used the following function to serialize the grid and it's data. But I can't seem to figure out how to build my grid and its content from the JSON array it created. Ive checked https://github.com/troolee/gridstack.js#load-grid-from-array, but adding the content part is the whole problem.
function saveData() {
var s_data = [];
$('.grid-stack-item.ui-draggable').each(function () {
var $this = $(this);
s_data.push({
x: $this.attr('data-gs-x'),
y: $this.attr('data-gs-y'),
w: $this.attr('data-gs-width'),
h: $this.attr('data-gs-height'),
content: $('.grid-stack-item-content', $this).html()
});
});
}
And that creates the following array:
[
{"x":"0","y":"0","w":"4","h":"2","content":"<h1>Test title for content</h1>"},
{"x":"4","y":"0","w":"4","h":"4","content":""}
];
So my question is: how can I build my grid, including its content, using this array?