diff --git a/rd_ui/app/scripts/directives/dashboard_directives.js b/rd_ui/app/scripts/directives/dashboard_directives.js
index 6142271c3..d39ae2c37 100644
--- a/rd_ui/app/scripts/directives/dashboard_directives.js
+++ b/rd_ui/app/scripts/directives/dashboard_directives.js
@@ -31,14 +31,14 @@
'
{name}' +
'
';
- $scope.$watch('dashboard.widgets', function(widgets) {
+ $scope.$watch('dashboard.widgets && dashboard.widgets.length', function(widgets_length) {
$timeout(function() {
gridster.remove_all_widgets();
- if (widgets && widgets.length) {
+ if ($scope.dashboard.widgets && $scope.dashboard.widgets.length) {
var layout = [];
- _.each(widgets, function(row, rowIndex) {
+ _.each($scope.dashboard.widgets, function(row, rowIndex) {
_.each(row, function(widget, colIndex) {
layout.push({
id: widget.id,
@@ -58,7 +58,7 @@
});
}
});
- }, true);
+ });
$scope.saveDashboard = function() {
$scope.saveInProgress = true;