]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectmenu: use dynamic binding for document event
authorFelix Nagel <info@felixnagel.com>
Wed, 15 May 2013 19:04:10 +0000 (21:04 +0200)
committerFelix Nagel <info@felixnagel.com>
Wed, 15 May 2013 19:04:10 +0000 (21:04 +0200)
ui/jquery.ui.selectmenu.js

index 339246304c86183deb522510a4312b827d81b595..76224fd7b7addb4efa0110f082a6f9ed20bef11d 100644 (file)
@@ -49,8 +49,6 @@ $.widget( "ui.selectmenu", {
                this._drawButton();
                this._drawMenu();
 
-               this._on( document, this._documentClick );
-
                if ( this.options.disabled ) {
                        this.disable();
                }
@@ -196,6 +194,8 @@ $.widget( "ui.selectmenu", {
                this._toggleAttr();
                this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
 
+               this._on( this.document, this._documentClick );
+
                this._trigger( "open", event );
        },
 
@@ -212,6 +212,8 @@ $.widget( "ui.selectmenu", {
                        this.menu.menu( "focus", null, this._getSelectedItem() );
                }
 
+               this._off( this.document );
+
                this._trigger( "close", event );
        },