Skip to content

Commit

Permalink
[dashboard] cleanup quietly to prevent error
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Apr 6, 2016
1 parent 4c70d69 commit 1dace5c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/plugins/kibana/public/dashboard/directives/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
});

$scope.$on('$destroy', function () {
safeLayout.cancel();
$window.off('resize', safeLayout);

if (!gridster) return;
gridster.$widgets.each(function (i, el) {
const panel = getPanelFor(el);
removePanel(panel);
// stop any animations
panel.$el.stop();
removePanel(panel, true);
// not that we will, but lets be safe
makePanelSerializeable(panel);
});
Expand Down Expand Up @@ -125,9 +126,9 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
}

// tell gridster to remove the panel, and cleanup our metadata
function removePanel(panel) {
function removePanel(panel, silent) {
// remove from grister 'silently' (don't reorganize after)
gridster.remove_widget(panel.$el);
gridster.remove_widget(panel.$el, silent);

// destroy the scope
panel.$scope.$destroy();
Expand Down

0 comments on commit 1dace5c

Please sign in to comment.