Skip to content

Commit

Permalink
fix "TypeError: Cannot read property 'off' of null"
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwalker committed Apr 24, 2014
1 parent 04c1848 commit 17f093f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/classes/eventProvider.js
Expand Up @@ -21,7 +21,7 @@
grid.$topPanel.on('mousedown', '.ngHeaderScroller', self.onHeaderMouseDown).on('dragover', '.ngHeaderScroller', self.dragOver);

grid.$groupPanel.on('$destroy', function() {
grid.$groupPanel.off('mousedown');
grid.$groupPanel && grid.$groupPanel.off('mousedown');

grid.$groupPanel = null;
});
Expand All @@ -31,10 +31,10 @@
}

grid.$topPanel.on('$destroy', function() {
grid.$topPanel.off('mousedown');
grid.$topPanel && grid.$topPanel.off('mousedown');

if (grid.config.enableColumnReordering) {
grid.$topPanel.off('drop');
grid.$topPanel && grid.$topPanel.off('drop');
}

grid.$topPanel = null;
Expand All @@ -45,7 +45,7 @@
$timeout(self.setDraggables);
}));
};
self.dragStart = function(evt){
self.dragStart = function(evt){
//FireFox requires there to be dataTransfer if you want to drag and drop.
evt.dataTransfer.setData('text', ''); //cannot be empty string
};
Expand Down Expand Up @@ -75,9 +75,9 @@
if (navigator.userAgent.indexOf("MSIE") !== -1){
//call native IE dragDrop() to start dragging
var sortColumn = grid.$root.find('.ngHeaderSortColumn');
sortColumn.bind('selectstart', function () {
this.dragDrop();
return false;
sortColumn.bind('selectstart', function () {
this.dragDrop();
return false;
});
angular.element(sortColumn).on('$destroy', function() {
sortColumn.off('selectstart');
Expand Down Expand Up @@ -111,17 +111,17 @@
if (!grid.config.jqueryUIDraggable) {
groupItem.attr('draggable', 'true');
if(this.addEventListener){//IE8 doesn't have drag drop or event listeners
this.addEventListener('dragstart', self.dragStart);
this.addEventListener('dragstart', self.dragStart);

angular.element(this).on('$destroy', function() {
this.removeEventListener('dragstart', self.dragStart);
this.removeEventListener('dragstart', self.dragStart);
});
}
if (navigator.userAgent.indexOf("MSIE") !== -1){
//call native IE dragDrop() to start dragging
groupItem.bind('selectstart', function () {
this.dragDrop();
return false;
groupItem.bind('selectstart', function () {
this.dragDrop();
return false;
});

groupItem.on('$destroy', function() {
Expand Down Expand Up @@ -216,7 +216,7 @@
self.assignGridEventHandlers = function() {
//Chrome and firefox both need a tab index so the grid can recieve focus.
//need to give the grid a tabindex if it doesn't already have one so
//we'll just give it a tab index of the corresponding gridcache index
//we'll just give it a tab index of the corresponding gridcache index
//that way we'll get the same result every time it is run.
//configurable within the options.
if (grid.config.tabIndex === -1) {
Expand Down
3 changes: 2 additions & 1 deletion src/services/DomUtilityService.js
Expand Up @@ -70,6 +70,7 @@
return width;
};
domUtilityService.UpdateGridLayout = function($scope, grid) {
if (!grid.$root) return;
//catch this so we can return the viewer to their original scroll after the resize!
var scrollTop = grid.$viewport.scrollTop();
grid.elementDims.rootMaxW = grid.$root.width();
Expand Down Expand Up @@ -163,4 +164,4 @@
domUtilityService.LetterW = 10;
getWidths();
return domUtilityService;
}]);
}]);

0 comments on commit 17f093f

Please sign in to comment.