Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tuizi opened this issue Apr 13, 2016 · 2 comments
Closed

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

Tuizi opened this issue Apr 13, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@Tuizi
Copy link

Tuizi commented Apr 13, 2016

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));
        }
    });
};
@Tuizi
Copy link
Author

Tuizi commented Apr 13, 2016

A workaround is to do:

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

gridStack.destroy(false);
gridStack.container.removeData("gridstack");

$('.grid-stack').gridstack(options); //Now, this works as expected

radiolips added a commit to radiolips/gridstack.js that referenced this issue Aug 17, 2016
@radiolips radiolips added this to the v0.2.7 milestone Aug 17, 2016
@radiolips radiolips mentioned this issue Aug 17, 2016
@radiolips
Copy link
Member

@Tuizi Apologies for the delay, but I believe you will no longer need to use your workaround. Thanks for your patience, and let us know if you're having any continued issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants