add detach_node param to remove_widget

This commit is contained in:
Pavel Reznikov 2015-03-08 23:33:14 -07:00
commit fc28ca5947
4 changed files with 16 additions and 11 deletions

View file

@ -36,7 +36,7 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
- [get_cell_from_pixel(position)](#get_cell_from_pixelposition)
- [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height)
- [locked(el, val)](#lockedel-val)
- [remove_widget(el)](#remove_widgetel)
- [remove_widget(el, detach_node)](#remove_widgetel-detach_node)
- [remove_all()](#remove_all)
- [resize(el, width, height)](#resizeel-width-height)
- [move(el, x, y)](#moveel-x-y)
@ -286,13 +286,14 @@ Locks/unlocks widget.
- `el` - widget to modify.
- `val` - if `true` widget will be locked.
### remove_widget(el)
### remove_widget(el, detach_node)
Removes widget from the grid.
Parameters:
- `el` - widget to remove
- `el` - widget to remove.
- `detach_node` - if `false` DOM node won't be removed from the tree (Optional. Default `true`).
### remove_all()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -673,12 +673,16 @@
return this.grid.can_be_placed_with_respect_to_height(node);
};
GridStack.prototype.remove_widget = function (el) {
GridStack.prototype.remove_widget = function (el, detach_node) {
detach_node = typeof detach_node === 'undefined' ? true : detach_node;
el = $(el);
var node = el.data('_gridstack_node');
this.grid.remove_node(node);
el.remove();
this._update_container_height();
if (detach_node)
el.remove();
else
el.data('_gridstack_node', null);
};
GridStack.prototype.remove_all = function () {
@ -694,7 +698,7 @@
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined') {
if (typeof node == 'undefined' || node == null) {
return;
}
@ -714,7 +718,7 @@
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined') {
if (typeof node == 'undefined' || node == null) {
return;
}
@ -744,7 +748,7 @@
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined') {
if (typeof node == 'undefined' || node == null) {
return;
}
@ -757,7 +761,7 @@
GridStack.prototype._update_element = function (el, callback) {
el = $(el).first();
var node = el.data('_gridstack_node');
if (typeof node == 'undefined') {
if (typeof node == 'undefined' || node == null) {
return;
}