Skip to main content

Search and Top Navigation

#5246 closed bug (fixed)

Opened March 02, 2010 12:07AM UTC

Closed March 11, 2010 03:50AM UTC

Last modified April 24, 2015 05:35AM UTC

_determineButtonType does not work if a label for checkbox/radiobutton is not yet attached to the document

Reported by: tomas Owned by: rdworth
Priority: blocker Milestone: 1.8
Component: ui.button Version: 1.8rc3
Keywords: Cc: thomas.nt@gmail.com
Blocked by: Blocking:
Description

Steps to reproduce:

#!js
$("body").appendItems(
  $('<div>')
    .append('<input type="checkbox" id="id1"><label for="id1">button1</label>')
    .buttonset()
);

This bug prevents simple building of complex DOM structures with buttons.

My suggestion is to replace the following line:

#!js
this.buttonElement = $( "[for=" + this.element.attr("id") + "]" );

with:

#!js
var selector = "[for=" + this.element.attr("id") + "]";
this.buttonElement = $( selector );
if (this.buttonElement.size() == 0)
  this.buttonElement = this.element.parent().last().find( selector );

Or some more efficient alternative:)

Attachments (0)
Change History (8)

Changed March 02, 2010 02:38AM UTC by scottgonzalez comment:1

The suggested fix isn't valid as it will only work in situations where the label happens to be the last element.

Changed March 02, 2010 01:12PM UTC by tomas comment:2

I am not sure whether I understand properly, but it works even if the label is not the last element:

#!js
$("body").appendItems(
  $('<div>')
    .append('<label for="id1">button1</label><input type="checkbox" id="id1">')
    .buttonset()
);

Changed March 10, 2010 05:31PM UTC by rdworth comment:3

milestone: TBD1.8
priority: minorblocker
version: 1.8rc21.8rc3

Changed March 10, 2010 05:51PM UTC by rdworth comment:4

owner: → rdworth
status: newassigned

Changed March 11, 2010 03:44AM UTC by scottgonzalez comment:5

Sorry, I saw the .parent() and misunderstood. I now realize you meant .parents() and I understand the logic you're using.

Changed March 11, 2010 03:50AM UTC by scottgonzalez comment:6

resolution: → fixed
status: assignedclosed

Fixed in r3883.

Changed March 13, 2010 08:22AM UTC by tomas comment:7

I see, sorry for typo.

Changed April 24, 2015 05:35AM UTC by chillaranand comment:8

same problem occurs if input is inside label http://fiddle.jshell.net/t2jhL9ru/5/