]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectmenu: make sure ui-state-focus class is set on button after initial focus
authorFelix Nagel <info@felixnagel.com>
Tue, 29 Oct 2013 20:49:17 +0000 (21:49 +0100)
committerFelix Nagel <info@felixnagel.com>
Tue, 29 Oct 2013 20:49:17 +0000 (21:49 +0100)
ui/jquery.ui.selectmenu.js

index 5c13a1619dbb791cce4b828f047bb1afa2c83ea4..45d3792403286655848d3389de6c621679a1f5b7 100644 (file)
@@ -56,7 +56,8 @@ $.widget( "ui.selectmenu", {
        },
 
        _drawButton: function() {
-               var tabindex = this.element.attr( "tabindex" );
+               var that = this,
+                       tabindex = this.element.attr( "tabindex" );
 
                // Associate existing label with the new button
                this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
@@ -96,6 +97,10 @@ $.widget( "ui.selectmenu", {
                this._setOption( "width", this.options.width );
 
                this._on( this.button, this._buttonEvents );
+               this.button.one( "focusin", function() {
+                       // Delay rendering the menu items until the button receives focus
+                       that._refreshMenu();
+               });
                this._hoverable( this.button );
                this._focusable( this.button );
        },
@@ -329,13 +334,6 @@ $.widget( "ui.selectmenu", {
        },
 
        _buttonEvents: {
-               focusin: function() {
-                       // Delay rendering the menu items until the button receives focus
-                       if ( !this.menuItems ) {
-                               this._refreshMenu();
-                       }
-                       this._off( this.button, "focusin" );
-               },
                click: "_toggle",
                keydown: function( event ) {
                        var preventDefault = true;