Merge commit 'b67ac87f7dd9cd35be939ddd43e71e15d0e7fa98'

This commit is contained in:
d 2016-02-22 09:42:36 -05:00
commit 1039368121
6 changed files with 30 additions and 13 deletions

View file

@ -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)

8
dist/gridstack.js vendored
View file

@ -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;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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)
@ -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)
@ -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:
@ -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

View file

@ -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;