Skip to content

Grid destroy() Does Not Remove Listeners #2213

@jasondalycan

Description

@jasondalycan

When destroying and recreating a grid that previously had a listener on it, the listener does not appear to be removed. Please see the following example code. The code below is called against an existing grid that needs to be recreated (SPA use-case):

widgetsGrid.destroy(false);
    
    widgetsGrid = GridStack.init(
        {   //column: 24,
            resizable: false,
            cellHeight: "40px",
            margin: 10,
        }, itemDiv);

    widgetsGrid.on("added", async function (event, items)
        {   console.log("Items: ", items);
         }

The above "added" event runs twice after the grid is destroyed and recreated with the above code. Shouldn't destroy remove the listeners as well? If not, how do you remove the listeners when destroying the grid?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions