Skip to content

Commit

Permalink
feat(gridster): destroy element's data and optionally remove from DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
vieron committed Mar 5, 2014
1 parent 04868a3 commit dc09f19
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/jquery.gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -3041,9 +3041,12 @@
* Destroy this gridster by removing any sign of its presence, making it easy to avoid memory leaks
*
* @method destroy
* @return {undefined}
* @param {Boolean} remove If true, remove gridster from DOM.
* @return {Object} Returns the instance of the Gridster class.
*/
fn.destroy = function(){
fn.destroy = function(remove) {
this.$el.removeData('gridster');

// remove bound callback on window resize
$(window).unbind('.gridster');

Expand All @@ -3053,10 +3056,7 @@

this.remove_style_tags();

// lastly, remove gridster element
// this will additionally cause any data associated to this element to be removed, including this
// very gridster instance
this.$el.remove();
remove && this.$el.remove();

return this;
};
Expand Down

0 comments on commit dc09f19

Please sign in to comment.