Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Change log
## 8.0.0-dev (TBD)
* feat: [#2275](https://github.com/gridstack/gridstack.js/issues/2275) `setupDragIn()` now can take an array or elements (in addition to selector string) and optional parent root (for shadow DOM support)
* fix: [#2234](https://github.com/gridstack/gridstack.js/issues/2234) `Utils.getElements('1')` (called by removeWidget() and others) now checks for digit 'selector' (becomes an id).
* fix: [#2213](https://github.com/gridstack/gridstack.js/issues/2213) `destroy()` now removes event handlers too

## 8.0.0 (2023-04-29)
* package is now ES2020 (TS exported files), webpack all.js still umd (better than commonjs for browsers), still have es5/ files unchanged (for now)
Expand Down
7 changes: 7 additions & 0 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ export class GridStack {
*/
public destroy(removeDOM = true): GridStack {
if (!this.el) return; // prevent multiple calls
this.offAll();
this._updateWindowResizeEvent(true);
this.setStatic(true, false); // permanently removes DD but don't set CSS class (we're going away)
this.setAnimation(false);
Expand Down Expand Up @@ -1064,6 +1065,12 @@ export class GridStack {
return this;
}

/** remove all event handlers */
public offAll(): GridStack {
Object.keys(this._gsEventHandler).forEach(key => this.off(key));
return this;
}

/**
* Removes widget from the grid.
* @param el widget or selector to modify
Expand Down