You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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).
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.
Activity
edborden commentedon Oct 5, 2015
I use Gridstack with Ember and use
add_widgetin 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?
gmsa commentedon Dec 10, 2015
+1
kdietrich commentedon Feb 12, 2016
You can use
remove_widgetwithdetach_node=falseto remove a widget without changing the DOM. The counterpartmake_widgetallows you to convert an existing node into a widget without gridstack creating another DOM node.jhpedemonte commentedon Feb 16, 2016
remove_widgetisn't enough. Callingdestroyon 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).radiolips commentedon Feb 18, 2016
We can add a parameter for
destroyto determine whether or not to remove from the DOM.gridstack#216 Add detachGrid parameter to destroy. Updated docs for r…
radiolips commentedon Feb 22, 2016
This feature has been merged in.
destroynow takes an optionaldetachGridmethod. Pass false and I believe your problem will be solved. Let me know if you have any further problems.