@@ -24,8 +24,8 @@ var autoComplete = (function(){
2424 // if (el.removeEventListener) not working in IE11
2525 if ( el . detachEvent ) el . detachEvent ( 'on' + type , handler ) ; else el . removeEventListener ( type , handler ) ;
2626 }
27- function live ( container , event , elClass , cb ) {
28- addEvent ( container , event , function ( e ) {
27+ function live ( event , elClass , cb , context ) {
28+ addEvent ( context || document , event , function ( e ) {
2929 var found , el = e . target || e . srcElement ;
3030 while ( el && ! ( found = hasClass ( el , elClass ) ) ) el = el . parentElement ;
3131 if ( found ) cb . call ( el , e ) ;
@@ -91,26 +91,26 @@ var autoComplete = (function(){
9191 addEvent ( window , 'resize' , that . updateSC ) ;
9292 document . body . appendChild ( that . sc ) ;
9393
94- live ( that . sc , 'mouseleave' , 'autocomplete-suggestion' , function ( e ) {
94+ live ( 'mouseleave' , 'autocomplete-suggestion' , function ( e ) {
9595 var sel = that . sc . querySelector ( '.autocomplete-suggestion.selected' ) ;
9696 if ( sel ) setTimeout ( function ( ) { sel . className = sel . className . replace ( 'selected' , '' ) ; } , 20 ) ;
97- } ) ;
97+ } , that . sc ) ;
9898
99- live ( that . sc , 'mouseover' , 'autocomplete-suggestion' , function ( e ) {
99+ live ( 'mouseover' , 'autocomplete-suggestion' , function ( e ) {
100100 var sel = that . sc . querySelector ( '.autocomplete-suggestion.selected' ) ;
101101 if ( sel ) sel . className = sel . className . replace ( 'selected' , '' ) ;
102102 this . className += ' selected' ;
103- } ) ;
103+ } , that . sc ) ;
104104
105- live ( that . sc , 'mouseup' , 'autocomplete-suggestion' , function ( e ) {
105+ live ( 'mouseup' , 'autocomplete-suggestion' , function ( e ) {
106106 if ( hasClass ( this , 'autocomplete-suggestion' ) ) { // else outside click
107107 var v = this . getAttribute ( 'data-val' ) ;
108108 that . value = v ;
109109 o . onSelect ( e , v , this ) ;
110110 that . focus ( ) ;
111111 that . sc . style . display = 'none' ;
112112 }
113- } ) ;
113+ } , that . sc ) ;
114114
115115 that . blurHandler = function ( ) {
116116 try { var over_sb = document . querySelector ( '.autocomplete-suggestions:hover' ) ; } catch ( e ) { var over_sb = 0 ; }
0 commit comments