Opened 13 years ago

Closed 13 years ago

Last modified 8 years ago

#5246 closed bug (fixed)

_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: [email protected]
Blocked by: Blocking:


Steps to reproduce:

    .append('<input type="checkbox" id="id1"><label for="id1">button1</label>')

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

My suggestion is to replace the following line:

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


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:)

Change History (8)

comment:1 Changed 13 years ago by Scott González

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

comment:2 Changed 13 years ago by tomas

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

    .append('<label for="id1">button1</label><input type="checkbox" id="id1">')

comment:3 Changed 13 years ago by rdworth

Milestone: TBD1.8
Priority: minorblocker
Version: 1.8rc21.8rc3

comment:4 Changed 13 years ago by rdworth

Owner: set to rdworth
Status: newassigned

comment:5 Changed 13 years ago by Scott González

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

comment:6 Changed 13 years ago by Scott González

Resolution: fixed
Status: assignedclosed

Fixed in r3883.

comment:7 Changed 13 years ago by tomas

I see, sorry for typo.

comment:8 Changed 8 years ago by chillaranand

same problem occurs if input is inside label

Note: See TracTickets for help on using tickets.