diff --git a/demo/serialization.html b/demo/serialization.html
index adaadace0..656832372 100644
--- a/demo/serialization.html
+++ b/demo/serialization.html
@@ -44,39 +44,45 @@
Serialization demo
{x: 1, y: 3, id: '4'}
];
serializedData.forEach((n, i) =>
- n.content = `
${i}
${n.content ? n.content : ''}`);
+ n.content = `
${i}
${n.content ? n.content : ''}`);
let serializedFull;
// 2.x method - just saving list of widgets with content (default)
- loadGrid = function() {
+ function loadGrid() {
grid.load(serializedData, true); // update things
}
// 2.x method
- saveGrid = function() {
+ function saveGrid() {
delete serializedFull;
serializedData = grid.save();
document.querySelector('#saved-data').value = JSON.stringify(serializedData, null, ' ');
}
// 3.1 full method saving the grid options + children (which is recursive for nested grids)
- saveFullGrid = function() {
+ function saveFullGrid() {
serializedFull = grid.save(true, true);
serializedData = serializedFull.children;
document.querySelector('#saved-data').value = JSON.stringify(serializedFull, null, ' ');
}
// 3.1 full method to reload from scratch - delete the grid and add it back from JSON
- loadFullGrid = function() {
+ function loadFullGrid() {
if (!serializedFull) return;
grid.destroy(true); // nuke everything
grid = GridStack.addGrid(document.querySelector('#gridCont'), serializedFull)
}
- clearGrid = function() {
+ function clearGrid() {
grid.removeAll();
}
+ function removeWidget(el) {
+ // TEST removing from DOM first like Angular/React/Vue would do
+ el.remove();
+ grid.removeWidget(el, false);
+ }
+
loadGrid();