Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit a0c6e1a

Browse files
author
Gabriel Schulhof
committed
Custom select: Moving binding that transfers focus from the native widget to the button into the widget prototype and calling it _handleSelectFocus().
1 parent a0ffdef commit a0c6e1a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

js/widgets/forms/select.custom.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
4848
return this._super();
4949
},
5050

51+
_handleSelectFocus: function() {
52+
this.element.blur();
53+
this.button.focus();
54+
},
55+
5156
build: function() {
5257
var selectId, prefix, popupId, dialogId, label, thisPage, isMultiple, menuId, themeAttr, overlayThemeAttr,
5358
dividerThemeAttr, menuPage, listbox, list, header, headerTitle, menuPageContent, menuPageClose, headerClose, self,
@@ -119,10 +124,8 @@ $.widget( "mobile.selectmenu", $.mobile.selectmenu, {
119124
// none present.
120125
this._origTabIndex = ( this.select[ 0 ].getAttribute( "tabindex" ) === null ) ? false : this.select.attr( "tabindex" );
121126
}
122-
this.select.attr( "tabindex", "-1" ).focus(function() {
123-
$( this ).blur();
124-
self.button.focus();
125-
});
127+
this.select.attr( "tabindex", "-1" );
128+
this._on( this.select, { focus : "_handleSelectFocus" } );
126129

127130
// Button events
128131
this.button.bind( "vclick keydown" , function( event ) {

0 commit comments

Comments
 (0)