diff --git a/README.md b/README.md index f33f4c5..cc131b9 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,15 @@ $grid.colcade('destroy') colc.destroy() ``` +Remove event listeners and instances, but preserve DOM as is. + +``` js +// jQuery +$grid.colcade('destroy', false) +// vanilla JS +colc.destroy(false) +``` + --- By David DeSandro diff --git a/colcade.js b/colcade.js index 67261ad..e2670bb 100644 --- a/colcade.js +++ b/colcade.js @@ -214,11 +214,13 @@ proto.onLoad = function( event ) { // ----- destroy ----- // -proto.destroy = function() { - // move items back to container - this.items.forEach( function( item ) { - this.element.appendChild( item ); - }, this ); +proto.destroy = function(moveItemsBack = true) { + if(moveItemsBack) { + // move items back to container + this.items.forEach( function( item ) { + this.element.appendChild( item ); + }, this ); + } // remove events window.removeEventListener( 'resize', this._windowResizeHandler ); this.element.removeEventListener( 'load', this._loadHandler, true );