diff --git a/src/js/core/services/ui-grid-util.js b/src/js/core/services/ui-grid-util.js index bd7334f464..c30ec654fa 100644 --- a/src/js/core/services/ui-grid-util.js +++ b/src/js/core/services/ui-grid-util.js @@ -1280,7 +1280,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC } }; s.off.mousewheel = function (elm, fn) { - var $elm = angular.element(this); + var $elm = angular.element(elm); var cbs = $elm.data('mousewheel-callbacks'); var handler = cbs[fn]; diff --git a/test/unit/core/services/ui-grid-util.spec.js b/test/unit/core/services/ui-grid-util.spec.js index a6fa788f30..84f133bfe0 100644 --- a/test/unit/core/services/ui-grid-util.spec.js +++ b/test/unit/core/services/ui-grid-util.spec.js @@ -612,4 +612,30 @@ describe('ui.grid.utilService', function() { }).not.toThrow(); }); }); + + describe('on.mousewheel', function() { + it('should register a callback on a dom element', function () { + var div = document.createElement('div'); + var $div = angular.element(div); + var callback = function(){}; + gridUtil.on.mousewheel(div, callback); + expect(Object.keys($div.data('mousewheel-callbacks')).length).toEqual(1); + }); + }); + + describe('off.mousewheel', function() { + it('should deregister a callback on a dom element', function () { + var div = document.createElement('div'); + var $div = angular.element(div); + var callback1 = function(){return 1;}; + var callback2 = function(){return 2;}; + gridUtil.on.mousewheel(div, callback1); + gridUtil.on.mousewheel(div, callback2); + expect(Object.keys($div.data('mousewheel-callbacks')).length).toEqual(2); + gridUtil.off.mousewheel(div, callback1); + expect(Object.keys($div.data('mousewheel-callbacks')).length).toEqual(1); + gridUtil.off.mousewheel(div, callback2); + expect($div.data('mousewheel-callbacks')).toBe(undefined); + }); + }); });