ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.04k stars 1.2k forks source link

How to remove gridster from DOM? #489

Open vko-online opened 9 years ago

vko-online commented 9 years ago

In source, there is a function

/**
     * Destroy this gridster by removing any sign of its presence, making it easy to avoid memory leaks
     *
     * @method destroy
     * @param {Boolean} remove If true, remove gridster from DOM.
     * @return {Object} Returns the instance of the Gridster class.
     */
    fn.destroy = function(remove) {
        this.$el.removeData('gridster');

        // remove bound callback on window resize
        $(window).unbind('.gridster');

        if (this.drag_api) {
            this.drag_api.destroy();
        }

        this.remove_style_tags();

        remove && this.$el.remove();

        return this;
    };

But how to call it or how to remove gridster from DOM

fhawkes commented 9 years ago
var gridster = $(".gridster").gridster({}).data('gridster');

gridster.destroy();

store the instance of gridster in a variable after you initialize it by calling .data('gridster') that will allow you to access the gridster api