dashboards
dashboards copied to clipboard
Gridstack: don't delete DOM nodes in destroy()
https://github.com/troolee/gridstack.js/issues/238 https://github.com/troolee/gridstack.js/issues/216
Currently, Gridstack allows us to pass an option to remove_widget()
so that the DOM node isn't removed from the container, but add_widget()
and destroy()
don't have those options.
In the meantime, we have created our own "subclass" of Gridstack which adds these options (code).
Use make_widget
to add a widget to gridstack without creating the DOM element.
troolee/gridstack.js#264
Using make_widget
instead of add_widget
will work, but there isn't yet a solution to destroy the Gridstack object without also destroying the DOM to which it is attached (see my comment here).
OK. We'll keep tracking.
Can't yet remove our destroy
workaround. A different approach would be to disable Gridstack when we are not using it, then reuse existing Gridstack when going back to dashboard mode.
One issue is that this approach would complicate our code. For one, we would need to keep track of cells added in the Notebook mode. There were some other issues that I can't recall at the moment. That's why we went with the simpler implementation of destroying the Gridstack instance and recreating from scratch.
(Updated title to remove mention of add_widget
)
Opened PR #196 to track updating Gridstack to a version that doesn't require us to monkey patch destroy
. However, I found there is still a bug when removing an individual cell -- see this discussion for more info.
Gridstack cut an official 0.2.5. Some highlights (from quick perusal of commits):
Use with require.js
If you're using require.js and a single file jQueryUI please check out this Stackoverflow question to get it working properly.
Grooming old issues ...
Gridstack 0.2.6 and up require jquery 3.1 and jquery-ui 1.12 (https://github.com/troolee/gridstack.js/releases/tag/v0.2.6). Notebook 5.0 is currently using to 2.0 and 1.10 respectively (https://github.com/jupyter/notebook/blob/5.0.0/bower.json#L12).
Trying to use gridstack 0.2.6 or 0.3.0 with what exists in notebook leads to undefined errors for the ui
parameter in many gridstack callbacks, possibly caused by the version mismatch.