diff options
author | Felix Nagel <info@felixnagel.com> | 2011-10-20 01:32:28 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2011-10-20 01:36:34 +0200 |
commit | 7a22385d97c77f551fe2475184661111f7b9cdf1 (patch) | |
tree | 8b975d211ac3bfff554d6130e32a86eea1dacba9 | |
parent | 410b0b6cd0f14b261d236abde2b79f2c16cc3cc2 (diff) | |
download | jquery-ui-7a22385d97c77f551fe2475184661111f7b9cdf1.tar.gz jquery-ui-7a22385d97c77f551fe2475184661111f7b9cdf1.zip |
improved: label event handling (backport of new version, see #140)
-rw-r--r-- | ui/jquery.ui.selectmenu.js | 24 |
1 files changed, 11 insertions, 13 deletions
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( '<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); |