]> source.dussan.org Git - jquery-ui.git/commitdiff
improved: label event handling (backport of new version, see #140)
authorFelix Nagel <info@felixnagel.com>
Wed, 19 Oct 2011 23:32:28 +0000 (01:32 +0200)
committerFelix Nagel <info@felixnagel.com>
Wed, 19 Oct 2011 23:36:34 +0000 (01:36 +0200)
ui/jquery.ui.selectmenu.js

index fa7e21aaf30bb9e44bf0a422373b5c778685bbfa..89b1c42059a9ebdf92a7f5ca16b0943fc46099e2 100644 (file)
@@ -77,13 +77,13 @@ $.widget("ui.selectmenu", {
                this.newelement.prepend( '<span class="' + self.widgetBaseClass + '-status" />' );
 
                // make associated form label trigger focus
-               $( 'label[for="' + selectmenuId + '"]' )
-                       .attr( 'for', this.ids[1] )
-                       .bind( 'click.selectmenu', function() {
-                               self.newelement[0].focus();
-                               return false;
-                       });
-
+               this.element.bind({
+                       'click.selectmenu':  function( event ) {
+                               self.newelement.focus();
+                               event.preventDefault();
+                       }
+               });
+               
                // click toggle for menu visibility
                this.newelement
                        .bind('mousedown.selectmenu', function(event) {
@@ -444,16 +444,14 @@ $.widget("ui.selectmenu", {
 
                $( window ).unbind( ".selectmenu-" + this.ids[0] );
                $( document ).unbind( ".selectmenu-" + this.ids[0] );
-
-               // unbind click on label, reset its for attr
-               $( 'label[for=' + this.ids[0] + ']' )
-                       .attr( 'for', this.ids[0] )
-                       .unbind( '.selectmenu' );
                
                this.newelementWrap.remove();
                this.listWrap.remove();
                
-               this.element.show();
+               // unbind click event and show original select
+               this.element
+                       .unbind(".selectmenu")
+                       .show();
 
                // call widget destroy function
                $.Widget.prototype.destroy.apply(this, arguments);