From: Felix Nagel Date: Wed, 19 Oct 2011 23:32:28 +0000 (+0200) Subject: improved: label event handling (backport of new version, see #140) X-Git-Tag: selectmenu_v1.2.0~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7a22385d97c77f551fe2475184661111f7b9cdf1;p=jquery-ui.git improved: label event handling (backport of new version, see #140) --- diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index fa7e21aaf..89b1c4205 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -77,13 +77,13 @@ $.widget("ui.selectmenu", { this.newelement.prepend( '' ); // 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);