diff --git a/src/jquery.gridster.js b/src/jquery.gridster.js index 79bd94151..e093b7d56 100755 --- a/src/jquery.gridster.js +++ b/src/jquery.gridster.js @@ -747,6 +747,7 @@ $el[this.options.hide_method]({ always: $.proxy(function() { + $el.coords().destroy(); $el.remove(); if (!silent) { @@ -3123,6 +3124,11 @@ */ fn.destroy = function(remove) { this.$el.removeData('gridster'); + this.$widgets.each($.proxy(function(i, el){ + $(el).coords().destroy(); + }, this)); + this.gridmap = null; + this.faux_grid = null; // remove bound callback on window resize $(window).unbind('.gridster'); diff --git a/test/index.js b/test/index.js index 90bf244e2..b0082fa93 100644 --- a/test/index.js +++ b/test/index.js @@ -328,8 +328,8 @@ describe('gridster.js', function() { it('should clean gridmap array', function() { this.gridster.destroy(); - expect(this.gridster.gridmap).to.be.empty; - expect(this.gridster.faux_grid).to.be.empty; + expect(this.gridster.gridmap).to.not.have.length; + expect(this.gridster.faux_grid).to.not.have.length; }); });