Permalink
Browse files

Selectmenu: create menu items with first opening to increase performance

  • Loading branch information...
1 parent db4acf6 commit 8c17f74a1e64e134108f790d2527df18284ac9cc @fnagel fnagel committed Jan 11, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 ui/jquery.ui.selectmenu.js
View
7 ui/jquery.ui.selectmenu.js
@@ -62,7 +62,6 @@ $.widget( "ui.selectmenu", {
this._bind( this.button, this._buttonEvents );
this._drawMenu();
- this.refresh();
},
_drawButton: function() {
@@ -191,6 +190,12 @@ $.widget( "ui.selectmenu", {
},
open: function( event ) {
+ // init menu when initial opened
+ if ( !this.wasOpen ) {
+ this.refresh();
+ this.wasOpen = true;
+ }
+
var currentItem = this._getSelectedItem();
if ( !this.options.disabled ) {

3 comments on commit 8c17f74

@jzaefferer
jQuery Foundation member

That's an easy fix, nice. Wondering if you could check some other state that refresh initializes, instead of introducing another one.

@fnagel
jQuery Foundation member

I could check for an attribute buts that more expensive than an var.

@fnagel
jQuery Foundation member

Nahh, it wasn't that easy. A fully initialized menu widget is needed for keyboard control. I needed to add a check in _move, too.

Please sign in to comment.