Skip to content

Commit

Permalink
gridstack#216 Add detachGrid parameter to destroy. Updated docs for r…
Browse files Browse the repository at this point in the history
…emove and removeAll param.
  • Loading branch information
radiolips committed Feb 22, 2016
1 parent d1c90cf commit de26b00
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ Changes
- add `setAnimation` method to API
- add `setGridWidth` method ([#227](https://github.com/troolee/gridstack.js/issues/227))
- add `removable`/`removeTimeout`
- add `detachGrid` parameter to `destroy` method ([#216](https://github.com/troolee/gridstack.js/issues/216))

#### v0.2.4 (2016-02-15)

Expand Down
8 changes: 6 additions & 2 deletions dist/gridstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,14 @@
this._updateContainerHeight();
};

GridStack.prototype.destroy = function() {
GridStack.prototype.destroy = function(detachGrid) {
$(window).off('resize', this.onResizeHandler);
this.disable();
this.container.remove();
if (typeof detachGrid != 'undefined' && !detachGrid) {
this.removeAll(true);
} else {
this.container.remove();
}
Utils.removeStylesheet(this._stylesId);
if (this.grid) {
this.grid = null;
Expand Down
2 changes: 1 addition & 1 deletion dist/gridstack.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gridstack.min.map

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gridstack.js API
- [cellHeight(val)](#cellheightval)
- [cellWidth()](#cellwidth)
- [commit()](#commit)
- [destroy()](#destroy)
- [destroy([detachGrid])](#destroydetachgrid)
- [disable()](#disable)
- [enable()](#enable)
- [enableMove(doEnable, includeNewWidgets)](#enablemovedoenable-includenewwidgets)
Expand All @@ -38,8 +38,8 @@ gridstack.js API
- [minWidth(el, val)](#minwidthel-val)
- [movable(el, val)](#movableel-val)
- [move(el, x, y)](#moveel-x-y)
- [removeWidget(el, detachNode)](#removewidgetel-detachnode)
- [removeAll()](#removeall)
- [removeWidget(el[, detachNode])](#removewidgetel-detachnode)
- [removeAll([detachNode])](#removealldetachnode)
- [resize(el, width, height)](#resizeel-width-height)
- [resizable(el, val)](#resizableel-val)
- [setAnimation(doAnimate)](#setanimationdoanimate)
Expand Down Expand Up @@ -220,10 +220,14 @@ Gets current cell width.

Finishes batch updates. Updates DOM nodes. You must call it after `batchUpdate`.

### destroy()
### destroy([detachGrid])

Destroys a grid instance.

Parameters:

- `detachGrid` - if `false` nodes and grid will not be removed from the DOM (Optional. Default `true`).

### disable()

Disables widgets moving/resizing. This is a shortcut for:
Expand Down Expand Up @@ -340,19 +344,23 @@ Parameters:
- `el` - widget to move
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.

### removeWidget(el, detachNode)
### removeWidget(el[, detachNode])

Removes widget from the grid.

Parameters:

- `el` - widget to remove.
- `detachNode` - if `false` DOM node won't be removed from the tree (Optional. Default `true`).
- `detachNode` - if `false` node won't be removed from the DOM (Optional. Default `true`).

### removeAll()
### removeAll([detachNode])

Removes all widgets from the grid.

Parameters:

- `detachNode` - if `false` nodes won't be removed from the DOM (Optional. Default `true`).

### resize(el, width, height)

Changes widget size
Expand Down
8 changes: 6 additions & 2 deletions src/gridstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,14 @@
this._updateContainerHeight();
};

GridStack.prototype.destroy = function() {
GridStack.prototype.destroy = function(detachGrid) {
$(window).off('resize', this.onResizeHandler);
this.disable();
this.container.remove();
if (typeof detachGrid != 'undefined' && !detachGrid) {
this.removeAll(true);
} else {
this.container.remove();
}
Utils.removeStylesheet(this._stylesId);
if (this.grid) {
this.grid = null;
Expand Down

0 comments on commit de26b00

Please sign in to comment.