Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.destroy(false) doesn't remove the data object #422

Closed
@Tuizi

Description

@Tuizi

Hello,

The destroy method with parameter false, doesn't remove the "data" object attach to the DOM.
Here is a example:

 $('.grid-stack').gridstack(options);

var gridStack = $('.grid-stack').data("gridstack");

console.debug(gridStack); // { Object }

gridStack.destroy(false);

var gridStack = $('.grid-stack').data("gridstack");

console.debug(gridStack); // { Object } **!!!!**

The problem with that if when, then, on the same DOM element I do:

$('.grid-stack').gridstack(options); //Will do nothing!

This code do nothing because the first thing you do is:

$.fn.gridstack = function(opts) {
    return this.each(function() {
        var o = $(this);
        if (!o.data('gridstack')) { // <= this will never be true, because destroy doesn't have removed this data object
            o
                .data('gridstack', new GridStack(this, opts));
        }
    });
};

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions