@@ -301,7 +301,7 @@ $.TokenList = function (input, url_or_data, settings) {
301
301
. hide ( )
302
302
. val ( "" )
303
303
. focus ( function ( ) {
304
- input_box . focus ( ) ;
304
+ focus_with_timeout ( input_box ) ;
305
305
} )
306
306
. blur ( function ( ) {
307
307
input_box . blur ( ) ;
@@ -326,7 +326,7 @@ $.TokenList = function (input, url_or_data, settings) {
326
326
}
327
327
328
328
// Focus input box
329
- input_box . focus ( ) ;
329
+ focus_with_timeout ( input_box ) ;
330
330
}
331
331
} )
332
332
. mouseover ( function ( event ) {
@@ -540,7 +540,7 @@ $.TokenList = function (input, url_or_data, settings) {
540
540
if ( found_existing_token ) {
541
541
select_token ( found_existing_token ) ;
542
542
input_token . insertAfter ( found_existing_token ) ;
543
- input_box . focus ( ) ;
543
+ focus_with_timeout ( input_box ) ;
544
544
return ;
545
545
}
546
546
}
@@ -594,7 +594,7 @@ $.TokenList = function (input, url_or_data, settings) {
594
594
}
595
595
596
596
// Show the input box and give it focus again
597
- input_box . focus ( ) ;
597
+ focus_with_timeout ( input_box ) ;
598
598
}
599
599
600
600
// Toggle selection of a token in the token list
@@ -626,7 +626,7 @@ $.TokenList = function (input, url_or_data, settings) {
626
626
selected_token = null ;
627
627
628
628
// Show the input box and give it focus again
629
- input_box . focus ( ) ;
629
+ focus_with_timeout ( input_box ) ;
630
630
631
631
// Remove this token from the saved list
632
632
saved_tokens = saved_tokens . slice ( 0 , index ) . concat ( saved_tokens . slice ( index + 1 ) ) ;
@@ -640,8 +640,8 @@ $.TokenList = function (input, url_or_data, settings) {
640
640
if ( settings . tokenLimit !== null ) {
641
641
input_box
642
642
. show ( )
643
- . val ( "" )
644
- . focus ( ) ;
643
+ . val ( "" ) ;
644
+ focus_with_timeout ( input_box ) ;
645
645
}
646
646
647
647
// Execute the onDelete callback if defined
@@ -867,6 +867,16 @@ $.TokenList = function (input, url_or_data, settings) {
867
867
}
868
868
return url ;
869
869
}
870
+
871
+ // Bring browser focus to the specified object.
872
+ // Use of setTimeout is to get around an IE bug.
873
+ // (See, e.g., http://stackoverflow.com/questions/2600186/focus-doesnt-work-in-ie)
874
+ //
875
+ // obj: a jQuery object to focus()
876
+ function focus_with_timeout ( obj ) {
877
+ setTimeout ( function ( ) { obj . focus ( ) ; } , 50 ) ;
878
+ }
879
+
870
880
} ;
871
881
872
882
// Really basic cache for the results
0 commit comments