Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db9eaea

Browse files
committed
Fix multi-grid issue
Fix moving widgets when using multiple grids. Fixes gridstack#1034
1 parent b386f2b commit db9eaea

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Change log
2424

2525
## v0.5.2-dev (upcoming changes)
2626

27+
- fix moving widgets when having multiple grids. jquery-ui workaround ([#1043](https://github.com/gridstack/gridstack.js/issues/1043)).
2728
- switch to eslint ([#763](https://github.com/gridstack/gridstack.js/issues/763)).
2829
- null values to addWidget() exception fix ([#1042](https://github.com/gridstack/gridstack.js/issues/1042)).
2930

src/gridstack.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,18 +974,24 @@
974974
draggingElement = el;
975975

976976
var node = self.grid._prepareNode({width: width, height: height, _added: false, _temporary: true});
977+
node.isOutOfGrid = true;
977978
el.data('_gridstack_node', node);
978979
el.data('_gridstack_node_orig', origNode);
979980

980981
el.on('drag', onDrag);
981982
})
982983
.on(self.container, 'dropout', function(event, ui) {
984+
// jquery-ui bug. Must verify widget is being dropped out
985+
// check node variable that gets set when widget is out of grid
983986
var el = $(ui.draggable);
984987
if (!el.data('_gridstack_node')) {
985988
return;
986989
}
987-
el.unbind('drag', onDrag);
988990
var node = el.data('_gridstack_node');
991+
if (!node.isOutOfGrid) {
992+
return;
993+
}
994+
el.unbind('drag', onDrag);
989995
node.el = null;
990996
self.grid.removeNode(node);
991997
self.placeholder.detach();
@@ -996,6 +1002,7 @@
9961002
self.placeholder.detach();
9971003

9981004
var node = $(ui.draggable).data('_gridstack_node');
1005+
node.isOutOfGrid = false;
9991006
node._grid = self;
10001007
var el = $(ui.draggable).clone(false);
10011008
el.data('_gridstack_node', node);

0 commit comments

Comments
 (0)