From 7a22385d97c77f551fe2475184661111f7b9cdf1 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Thu, 20 Oct 2011 01:32:28 +0200 Subject: [PATCH] improved: label event handling (backport of new version, see #140) --- ui/jquery.ui.selectmenu.js | 24 +++++++++++------------- 1 file 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( '' ); // 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); -- 2.39.5