File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ $(function () {
47
47
} ,
48
48
onHint : function ( hint ) {
49
49
$ ( '#autocomplete-ajax-x' ) . val ( hint ) ;
50
+ } ,
51
+ onInvalidateSelection : function ( ) {
52
+ $ ( '#selction-ajax' ) . html ( 'You selected: none' ) ;
50
53
}
51
54
} ) ;
52
55
Original file line number Diff line number Diff line change 100
100
} ;
101
101
that . hint = null ;
102
102
that . hintValue = '' ;
103
+ that . selection = null ;
103
104
104
105
// Initialize and set options:
105
106
that . initialize ( ) ;
178
179
that . el . on ( 'keyup.autocomplete' , function ( e ) { that . onKeyUp ( e ) ; } ) ;
179
180
that . el . on ( 'blur.autocomplete' , function ( ) { that . onBlur ( ) ; } ) ;
180
181
that . el . on ( 'focus.autocomplete' , function ( ) { that . fixPosition ( ) ; } ) ;
182
+ that . el . on ( 'change.autocomplete' , function ( e ) { that . onKeyUp ( e ) ; } ) ;
181
183
} ,
182
184
183
185
onBlur : function ( ) {
347
349
return ;
348
350
}
349
351
350
- that . findBestHint ( ) ;
351
-
352
352
clearInterval ( that . onChangeInterval ) ;
353
353
354
354
if ( that . currentValue !== that . el . val ( ) ) {
355
+ that . findBestHint ( ) ;
355
356
if ( that . options . deferRequestBy > 0 ) {
356
357
// Defer lookup in case when value changes very quickly:
357
358
that . onChangeInterval = setInterval ( function ( ) {
367
368
var that = this ,
368
369
q ;
369
370
371
+ if ( that . selection ) {
372
+ that . selection = null ;
373
+ ( that . options . onInvalidateSelection || $ . noop ) ( ) ;
374
+ }
375
+
370
376
clearInterval ( that . onChangeInterval ) ;
371
377
that . currentValue = that . el . val ( ) ;
372
378
654
660
that . el . val ( that . currentValue ) ;
655
661
that . signalHint ( null ) ;
656
662
that . suggestions = [ ] ;
663
+ that . selection = suggestion ;
657
664
658
665
if ( $ . isFunction ( onSelectCallback ) ) {
659
666
onSelectCallback . call ( that . element , suggestion ) ;
You can’t perform that action at this time.
0 commit comments