Skip to content

Commit 3e9cea5

Browse files
committed
Fix $document.off()
1 parent 777c804 commit 3e9cea5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/select.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ angular.module('ui.select', [])
174174
ctrl.refresh = function(refreshAttr) {
175175
if (refreshAttr !== undefined) {
176176

177-
// Throttle / debounce
178-
//
177+
// Debounce
179178
// See https://github.com/angular-ui/bootstrap/blob/0.10.0/src/typeahead/typeahead.js#L155
180179
// FYI AngularStrap typeahead does not have debouncing: https://github.com/mgcrea/angular-strap/blob/v2.0.0-rc.4/src/typeahead/typeahead.js#L177
181180
if (_refreshDelayPromise) {
@@ -233,7 +232,6 @@ angular.module('ui.select', [])
233232
}
234233

235234
// Bind to keyboard shortcuts
236-
// Cannot specify a namespace: not supported by jqLite
237235
_searchInput.on('keydown', function(e) {
238236
// Keyboard shortcuts are all about the items,
239237
// does not make sense (and will crash) if ctrl.items is empty
@@ -324,8 +322,7 @@ angular.module('ui.select', [])
324322
$select.selected = ngModel.$viewValue;
325323
};
326324

327-
// See Click everywhere but here event http://stackoverflow.com/questions/12931369
328-
$document.on('mousedown', function(e) {
325+
function onDocumentClick(e) {
329326
var contains = false;
330327

331328
if (window.jQuery) {
@@ -340,10 +337,13 @@ angular.module('ui.select', [])
340337
$select.close();
341338
scope.$digest();
342339
}
343-
});
340+
}
341+
342+
// See Click everywhere but here event http://stackoverflow.com/questions/12931369
343+
$document.on('click', onDocumentClick);
344344

345345
scope.$on('$destroy', function() {
346-
$document.off('mousedown');
346+
$document.off('click', onDocumentClick);
347347
});
348348

349349
// Move transcluded elements to their correct position in main template

0 commit comments

Comments
 (0)