diff --git a/static/js/controllers.js b/static/js/controllers.js index 1ea6fd055..25745ff0e 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -402,11 +402,16 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim }; var listImages = function() { - if ($scope.imageHistory) { return; } - var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/'); imageFetch.get().then(function(resp) { $scope.imageHistory = resp.images; + + // Dispose of any existing tree. + if ($scope.tree) { + $scope.tree.dispose(); + } + + // Create the new tree. $scope.tree = new ImageHistoryTree(namespace, name, resp.images, $scope.getCommentFirstLine, $scope.getTimeSince); @@ -418,7 +423,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim } $($scope.tree).bind('tagChanged', function(e) { - $scope.$apply(function() { $scope.setTag(e.tag, true); }); + $scope.$apply(function() { $scope.setTag(e.tag, true); }); }); $($scope.tree).bind('imageChanged', function(e) { $scope.$apply(function() { $scope.setImage(e.image); }); diff --git a/static/js/graphing.js b/static/js/graphing.js index c38ee273e..88aedc5da 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -809,6 +809,16 @@ ImageFileChangeTree.prototype.notifyResized = function() { }; +/** + * Disposes of the tree. + */ +ImageFileChangeTree.prototype.dispose = function() { + var container = this.container_ ; + $('#' + container).removeOverscroll(); + document.getElememtById(container).innerHTML = ''; +}; + + /** * Draws the tree. */