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

Enhancement: clean destroy #218

Open
rochejul opened this issue Aug 21, 2013 · 2 comments
Open

Enhancement: clean destroy #218

rochejul opened this issue Aug 21, 2013 · 2 comments

Comments

@rochejul
Copy link

Hi,

I have a case where I need to reinstanciate the gridster (on window resize). But I cannot use the destroy method, because it delete the DOM elements.

And we have to clean properly on destroy, because the reinstanciation can inject some problems (drag / drop not managed ...).

If you want, I produce a function to resolve that:

fn.destroy = function(removeDOM) {
$(window).unbind('.gridster');

if (this.drag_api) {
    this.drag_api.destroy();
    this.$el.removeData('drag');
}

this.remove_style_tags();
this.removeData('gridster');

if(removeDOM === undefined || removeDOM === true) {
    this.$el.remove();
}

return this;

};

Cheers

Julien Roche

@egorgrushin
Copy link

SUPER! IT Resolved my problems! Very thx to you!

@KamilPesek
Copy link

KamilPesek commented Feb 7, 2017

This works for me:
V0.7.0

 var gridster = $(".gridster ul").gridster({
                ... options
 });

gridster.removeData('drag');
gridster.data('gridster').destroy();

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

No branches or pull requests

3 participants