#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: |
Description
Steps to reproduce:
$("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:
this.buttonElement = $( "[for=" + this.element.attr("id") + "]" );
with:
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
comment:2 Changed 13 years ago by
I am not sure whether I understand properly, but it works even if the label is not the last element:
$("body").appendItems( $('<div>') .append('<label for="id1">button1</label><input type="checkbox" id="id1">') .buttonset() );
comment:3 Changed 13 years ago by
Milestone: | TBD → 1.8 |
---|---|
Priority: | minor → blocker |
Version: | 1.8rc2 → 1.8rc3 |
comment:4 Changed 13 years ago by
Owner: | set to rdworth |
---|---|
Status: | new → assigned |
comment:5 Changed 13 years ago by
Sorry, I saw the .parent() and misunderstood. I now realize you meant .parents() and I understand the logic you're using.
comment:8 Changed 8 years ago by
same problem occurs if input is inside label http://fiddle.jshell.net/t2jhL9ru/5/
Note: See
TracTickets for help on using
tickets.
The suggested fix isn't valid as it will only work in situations where the label happens to be the last element.