This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-10
lines changed Expand file tree Collapse file tree 2 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -79,12 +79,22 @@ angular.module('ui.select', [])
79
79
scope . $select . selected = ngModelCtrl . $viewValue ;
80
80
} ;
81
81
82
- $document . on ( 'click' , function ( evt ) {
83
- if ( angular . element ( evt . target ) . hasClass ( 'ui-select-search' ) ) {
84
- return ;
82
+ // See Click everywhere but here event http://stackoverflow.com/questions/12931369/click-everywhere-but-here-event
83
+ $document . on ( 'mousedown' , function ( evt ) {
84
+ var contains = false ;
85
+
86
+ if ( window . jQuery ) {
87
+ // Firefox 3.6 does not support element.contains()
88
+ // See Node.contains https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
89
+ contains = $ . contains ( element [ 0 ] , evt . target ) ;
90
+ } else {
91
+ contains = element [ 0 ] . contains ( evt . target ) ;
92
+ }
93
+
94
+ if ( ! contains ) {
95
+ uiSelectCtrl . close ( ) ;
96
+ scope . $digest ( ) ;
85
97
}
86
- uiSelectCtrl . close ( ) ; // Close if clicking outside
87
- scope . $digest ( ) ;
88
98
} ) ;
89
99
90
100
// Move transcluded elements to their correct position on main template
Original file line number Diff line number Diff line change @@ -79,12 +79,22 @@ angular.module('ui.select', [])
79
79
scope . $select . selected = ngModelCtrl . $viewValue ;
80
80
} ;
81
81
82
- $document . on ( 'click' , function ( evt ) {
83
- if ( angular . element ( evt . target ) . hasClass ( 'ui-select-search' ) ) {
84
- return ;
82
+ // See Click everywhere but here event http://stackoverflow.com/questions/12931369/click-everywhere-but-here-event
83
+ $document . on ( 'mousedown' , function ( evt ) {
84
+ var contains = false ;
85
+
86
+ if ( window . jQuery ) {
87
+ // Firefox 3.6 does not support element.contains()
88
+ // See Node.contains https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
89
+ contains = $ . contains ( element [ 0 ] , evt . target ) ;
90
+ } else {
91
+ contains = element [ 0 ] . contains ( evt . target ) ;
92
+ }
93
+
94
+ if ( ! contains ) {
95
+ uiSelectCtrl . close ( ) ;
96
+ scope . $digest ( ) ;
85
97
}
86
- uiSelectCtrl . close ( ) ; // Close if clicking outside
87
- scope . $digest ( ) ;
88
98
} ) ;
89
99
90
100
// Move transcluded elements to their correct position on main template
You can’t perform that action at this time.
0 commit comments