},
_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 );
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 );
},
},
_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;