Fixed memory leak in bootstrap Typeahead code, Fixes #1497

pull/1564/head
Torkel Ödegaard 10 years ago
parent 7293ee0894
commit 97e5a04621
  1. 8
      src/app/directives/grafanaPanel.js
  2. 5
      src/app/directives/templateParamSelector.js
  3. 17
      src/app/features/dashboard/dashboardCtrl.js
  4. 7
      src/vendor/bootstrap/bootstrap.js

@ -37,14 +37,6 @@ function (angular, $, config) {
var getter = $parse(attr.type), panelType = getter($scope);
var newScope = $scope.$new();
$scope.kbnJqUiDraggableOptions = {
revert: 'invalid',
helper: function() {
return $('<div style="width:200px;height:100px;background: rgba(100,100,100,0.50);"/>');
},
placeholder: 'keep'
};
// compile the module and uncloack. We're done
function loadModule($module) {
$module.appendTo(elem);

@ -75,6 +75,11 @@ function (angular, app, _, $) {
$button.focus();
});
$scope.$on('$destroy', function() {
$button.unbind();
typeahead.destroy();
});
$compile(elem.contents())($scope);
}
};

@ -31,13 +31,6 @@ function (angular, $, config, _) {
$scope.setupDashboard(dashboardData);
};
$scope.registerWindowResizeEvent = function() {
angular.element(window).bind('resize', function() {
$timeout.cancel(resizeEventTimeout);
resizeEventTimeout = $timeout(function() { $scope.$broadcast('render'); }, 200);
});
};
$scope.setupDashboard = function(dashboardData) {
$rootScope.performance.dashboardLoadStart = new Date().getTime();
$rootScope.performance.panelsInitialized = 0;
@ -127,5 +120,15 @@ function (angular, $, config, _) {
$rootScope.$broadcast('render');
};
$scope.registerWindowResizeEvent = function() {
angular.element(window).bind('resize', function() {
$timeout.cancel(resizeEventTimeout);
resizeEventTimeout = $timeout(function() { $scope.$broadcast('render'); }, 200);
});
$scope.$on('$destroy', function() {
angular.element(window).unbind('resize');
});
};
});
});

@ -1956,7 +1956,7 @@
return items ? this.process(items) : this
}
, process: function (items) {
, process: function (items) {
var that = this
items = $.grep(items, function (item) {
@ -2050,6 +2050,11 @@
.on('click', $.proxy(this.click, this))
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
.on('mouseleave', 'li', $.proxy(this.mouseleave, this))
},
destroy: function () {
this.$element.off().removeData('typeahead');
this.$menu.off();
}
, eventSupported: function(eventName) {

Loading…
Cancel
Save