-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Subject of the issue
When dealing with multiple grids, removeAll()
is not suitable with widget-based grids.
Your environment
- version of gridstack.js: 0.5
- which browser and its version: FF 6x
Steps to reproduce
Multiple grids handling with widgets is good. But coupling with save/load we soon hit an issue if we want a reset
. The two demo avoids because there is no such thing like "reference/default grid".
In my case, instead of removeAll()
I'm looking into moving back all widgets to #grid1 so we can start filling grid2 again
.
- A pure "items" based version does not fit since it'd loose the individual DOM elements.
- (side topic) I thought about doing that, but couldn't find an actual way to extends core GridStack methods.
$(function () {
GridStack.prototype.moveAll = function(new_grid) {
this.grid.nodes.forEach(function(node) {
new_grid.data('gridstack').addWidget(node.el);
this.removeWidget(node.el, /* detachNode */ false);
}, this);
this.grid.nodes = [];
this._updateContainerHeight();
};
});
- I'm currently using
removed
event:
$("#grid2").data("gridstack").on('removed', function(event, items) {
for (var o of items) {
$('#grid1').data('gridstack').addWidget(o.el);
}
The latest is somehow working but it's not very robust (the event
is not fire under some conditions) and think API could ease that common use-case.
Metadata
Metadata
Assignees
Labels
No labels