|
673 | 673 | return this.grid.can_be_placed_with_respect_to_height(node);
|
674 | 674 | };
|
675 | 675 |
|
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; |
677 | 678 | el = $(el);
|
678 | 679 | var node = el.data('_gridstack_node');
|
679 | 680 | this.grid.remove_node(node);
|
680 |
| - el.remove(); |
| 681 | + el.removeData('_gridstack_node'); |
681 | 682 | this._update_container_height();
|
| 683 | + if (detach_node) |
| 684 | + el.remove(); |
682 | 685 | };
|
683 | 686 |
|
684 |
| - GridStack.prototype.remove_all = function () { |
| 687 | + GridStack.prototype.remove_all = function (detach_node) { |
685 | 688 | _.each(this.grid.nodes, function (node) {
|
686 |
| - node.el.remove(); |
687 |
| - }); |
| 689 | + this.remove_widget(node.el, detach_node); |
| 690 | + }, this); |
688 | 691 | this.grid.nodes = [];
|
689 | 692 | this._update_container_height();
|
690 | 693 | };
|
|
694 | 697 | el.each(function (index, el) {
|
695 | 698 | el = $(el);
|
696 | 699 | var node = el.data('_gridstack_node');
|
697 |
| - if (typeof node == 'undefined') { |
| 700 | + if (typeof node == 'undefined' || node == null) { |
698 | 701 | return;
|
699 | 702 | }
|
700 | 703 |
|
|
714 | 717 | el.each(function (index, el) {
|
715 | 718 | el = $(el);
|
716 | 719 | var node = el.data('_gridstack_node');
|
717 |
| - if (typeof node == 'undefined') { |
| 720 | + if (typeof node == 'undefined' || node == null) { |
718 | 721 | return;
|
719 | 722 | }
|
720 | 723 |
|
|
744 | 747 | el.each(function (index, el) {
|
745 | 748 | el = $(el);
|
746 | 749 | var node = el.data('_gridstack_node');
|
747 |
| - if (typeof node == 'undefined') { |
| 750 | + if (typeof node == 'undefined' || node == null) { |
748 | 751 | return;
|
749 | 752 | }
|
750 | 753 |
|
|
757 | 760 | GridStack.prototype._update_element = function (el, callback) {
|
758 | 761 | el = $(el).first();
|
759 | 762 | var node = el.data('_gridstack_node');
|
760 |
| - if (typeof node == 'undefined') { |
| 763 | + if (typeof node == 'undefined' || node == null) { |
761 | 764 | return;
|
762 | 765 | }
|
763 | 766 |
|
|
0 commit comments