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

Skip to content

Commit bfaa893

Browse files
committed
update gridstack.js
1 parent 39df7fa commit bfaa893

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

gridstack.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -673,18 +673,21 @@
673673
return this.grid.can_be_placed_with_respect_to_height(node);
674674
};
675675

676-
GridStack.prototype.remove_widget = function (el) {
676+
GridStack.prototype.remove_widget = function (el, detach_node) {
677+
detach_node = typeof detach_node === 'undefined' ? true : detach_node;
677678
el = $(el);
678679
var node = el.data('_gridstack_node');
679680
this.grid.remove_node(node);
680-
el.remove();
681+
el.removeData('_gridstack_node');
681682
this._update_container_height();
683+
if (detach_node)
684+
el.remove();
682685
};
683686

684-
GridStack.prototype.remove_all = function () {
687+
GridStack.prototype.remove_all = function (detach_node) {
685688
_.each(this.grid.nodes, function (node) {
686-
node.el.remove();
687-
});
689+
this.remove_widget(node.el, detach_node);
690+
}, this);
688691
this.grid.nodes = [];
689692
this._update_container_height();
690693
};
@@ -694,7 +697,7 @@
694697
el.each(function (index, el) {
695698
el = $(el);
696699
var node = el.data('_gridstack_node');
697-
if (typeof node == 'undefined') {
700+
if (typeof node == 'undefined' || node == null) {
698701
return;
699702
}
700703

@@ -714,7 +717,7 @@
714717
el.each(function (index, el) {
715718
el = $(el);
716719
var node = el.data('_gridstack_node');
717-
if (typeof node == 'undefined') {
720+
if (typeof node == 'undefined' || node == null) {
718721
return;
719722
}
720723

@@ -744,7 +747,7 @@
744747
el.each(function (index, el) {
745748
el = $(el);
746749
var node = el.data('_gridstack_node');
747-
if (typeof node == 'undefined') {
750+
if (typeof node == 'undefined' || node == null) {
748751
return;
749752
}
750753

@@ -757,7 +760,7 @@
757760
GridStack.prototype._update_element = function (el, callback) {
758761
el = $(el).first();
759762
var node = el.data('_gridstack_node');
760-
if (typeof node == 'undefined') {
763+
if (typeof node == 'undefined' || node == null) {
761764
return;
762765
}
763766

0 commit comments

Comments
 (0)