From a0636f15f4691045a4439a10861119633ddd5766 Mon Sep 17 00:00:00 2001 From: fajan Date: Wed, 17 Oct 2012 23:41:27 +0300 Subject: [PATCH] Button: input inside label fix for ticket #6063 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Button: input inside label fix. Ticket #6063: Labels with implicit controls are not converted to buttons. So far it works for in Chrome (18.0.1025), FF (16.0.1), Opera (12.02). --- ui/jquery.ui.button.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index f253464df6a..919db8d1723 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -213,7 +213,7 @@ $.widget( "ui.button", { }, _determineButtonType: function() { - var ancestor, labelSelector, checked; + var ancestor, labelSelector, checked, tempElement; if ( this.element.is("[type=checkbox]") ) { this.type = "checkbox"; @@ -236,6 +236,17 @@ $.widget( "ui.button", { this.buttonElement = ancestor.filter( labelSelector ); if ( !this.buttonElement.length ) { this.buttonElement = ancestor.find( labelSelector ); + if ( !this.buttonElement.length ) { + ancestor = this.element.parents('label:first'); + if (ancestor.length){ + this.element.detach(); + tempElement = this.element; + setTimeout(function(){ + ancestor.prepend(tempElement); + },1); + this.buttonElement = ancestor; + } + } } } this.element.addClass( "ui-helper-hidden-accessible" );