Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/features/edit/js/gridEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,11 @@
});


$scope.$on( '$destroy', rowWatchDereg );
$scope.$on('$destroy', function destroyEvents() {
rowWatchDereg();
// unbind all jquery events in order to avoid memory leaks
$elm.off();
});

function registerBeginEditEvents() {
$elm.on('dblclick', beginEdit);
Expand Down Expand Up @@ -1042,6 +1046,11 @@

return true;
});

$scope.$on('$destroy', function unbindEvents() {
// unbind all jquery events in order to avoid memory leaks
$elm.off();
});
}
};
}
Expand Down Expand Up @@ -1185,6 +1194,11 @@
}
return true;
});

$scope.$on('$destroy', function unbindEvents() {
// unbind jquery events to prevent memory leaks
$elm.off();
});
}
};
}
Expand Down Expand Up @@ -1277,7 +1291,7 @@
}
};

$elm[0].addEventListener('change', handleFileSelect, false); // TODO: why the false on the end? Google
$elm[0].addEventListener('change', handleFileSelect, false);

$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
$elm[0].focus();
Expand All @@ -1287,11 +1301,15 @@
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
});
});

$scope.$on('$destroy', function unbindEvents() {
// unbind jquery events to prevent memory leaks
$elm.off();
$elm[0].removeEventListener('change', handleFileSelect, false);
});
}
};
}
};
}]);


})();
2 changes: 2 additions & 0 deletions src/features/move-columns/js/column-movable.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@
movingElm.css({'width': reducedWidth + 'px'});
}
};

$scope.$on('$destroy', offAllEvents);
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/features/selection/js/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,10 @@
window.setTimeout(function () { evt.target.onselectstart = null; }, 0);
}
}

$scope.$on('$destroy', function unbindEvents() {
$elm.off();
});
}
};
}]);
Expand Down
10 changes: 4 additions & 6 deletions src/js/core/directives/ui-grid-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,11 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
angular.element($window).on('resize', applyHideMenu);
}

$scope.$on('$destroy', function () {
angular.element(document).off('click touchstart', applyHideMenu);
});


$scope.$on('$destroy', function() {
$scope.$on('$destroy', function unbindEvents() {
angular.element($window).off('resize', applyHideMenu);
angular.element(document).off('click touchstart', applyHideMenu);
$elm.off('keyup', checkKeyUp);
$elm.off('keydown', checkKeyDown);
});

if (uiGridCtrl) {
Expand Down
4 changes: 3 additions & 1 deletion src/js/core/directives/ui-grid-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
}
}


$scope.$on('$destroy', function unbindEvents() {
$elm.off();
});
},
controller: ['$scope', function ($scope) {
this.rowStyle = function (index) {
Expand Down
5 changes: 5 additions & 0 deletions src/js/core/services/ui-grid-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,11 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
for ( var i = mouseWheeltoBind.length; i; ) {
$elm.on(mouseWheeltoBind[--i], cbs[fn]);
}
$elm.on('$destroy', function unbindEvents() {
for ( var i = mouseWheeltoBind.length; i; ) {
$elm.off(mouseWheeltoBind[--i], cbs[fn]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like it may be something that needs additional refactoring

}
});
};
s.off.mousewheel = function (elm, fn) {
var $elm = angular.element(elm);
Expand Down