Skip to content

Destroy shouldn't delete DOM #216

Closed
Closed

Description

@mistahenry

Hey, great plugin. My major issue with it is that the destroy method actually deletes the DOM. I was hoping it would merely uninit the dashboard. I am using Ember.js and here's my use case. When adding a widget, I simply added it to an array which causes a rerender which adds another widget into the dashboard (thanks to two-way binding). The problem is that this new widget isn't considered a part of the dashboard even though it has all of the correct data attributes. So I thought I'll do what I do with other plugins. Call destroy, the init again. Only, I lost all of my DOM :(

See, your add_widget method is not conducive to Ember because it requires that I pass html to the helper method itself, which isn't at all what I want to do from an Ember perspective. It'd be nice to either not destroy the DOM or provide a way to add a widget to the dashboard that already exists in the DOM to the dashboard container. As in, don't programmatically create a new widget for me. Let me specify that this widget doesn't currently exist in the dashboard but it should, so add it.

Activity

  1. edborden commented on Oct 5, 2015

    @edborden

    I use Gridstack with Ember and use add_widget in setup like this:
    didInsertElement: -> scheduleOnce 'afterRender', @, 'setupGridstackWidget'

    I haven't been able to grock what the "right way" to integrate plugins that directly manipulate the DOM with Ember, though. What am I missing?

  2. gmsa commented on Dec 10, 2015

    @gmsa

    +1

  3. kdietrich commented on Feb 12, 2016

    @kdietrich

    You can use remove_widget with detach_node=false to remove a widget without changing the DOM. The counterpart make_widget allows you to convert an existing node into a widget without gridstack creating another DOM node.

  4. jhpedemonte commented on Feb 16, 2016

    @jhpedemonte

    remove_widget isn't enough. Calling destroy on the Gridstack object does cleanup for the whole grid, not just an individual widget. Looking at the code, it removes a "resize" handler and style rules (as well as removing the container from the DOM, which is what we want to avoid in this issue).

  5. radiolips commented on Feb 18, 2016

    @radiolips
    Member

    We can add a parameter for destroy to determine whether or not to remove from the DOM.

  6. added this to the v0.2.5 milestone on Feb 18, 2016
  7. added a commit that references this issue on Feb 22, 2016
  8. radiolips commented on Feb 22, 2016

    @radiolips
    Member

    This feature has been merged in. destroy now takes an optional detachGrid method. Pass false and I believe your problem will be solved. Let me know if you have any further problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions