Skip to content

Commit dc09f19

Browse files
committedMar 5, 2014
feat(gridster): destroy element's data and optionally remove from DOM
1 parent 04868a3 commit dc09f19

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎src/jquery.gridster.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -3041,9 +3041,12 @@
30413041
* Destroy this gridster by removing any sign of its presence, making it easy to avoid memory leaks
30423042
*
30433043
* @method destroy
3044-
* @return {undefined}
3044+
* @param {Boolean} remove If true, remove gridster from DOM.
3045+
* @return {Object} Returns the instance of the Gridster class.
30453046
*/
3046-
fn.destroy = function(){
3047+
fn.destroy = function(remove) {
3048+
this.$el.removeData('gridster');
3049+
30473050
// remove bound callback on window resize
30483051
$(window).unbind('.gridster');
30493052

@@ -3053,10 +3056,7 @@
30533056

30543057
this.remove_style_tags();
30553058

3056-
// lastly, remove gridster element
3057-
// this will additionally cause any data associated to this element to be removed, including this
3058-
// very gridster instance
3059-
this.$el.remove();
3059+
remove && this.$el.remove();
30603060

30613061
return this;
30623062
};

0 commit comments

Comments
 (0)