Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Checkboxradio: Clicking on an unnamed radio button must also work
Browse files Browse the repository at this point in the history
Closes gh-6659
Closes gh-7082
Fixes gh-7088
  • Loading branch information
Gabriel Schulhof committed Feb 8, 2014
1 parent 4696651 commit 834d5f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/widgets/forms/checkboxradio.js
Expand Up @@ -188,8 +188,11 @@ $.widget( "mobile.checkboxradio", $.extend( {
return this.element;
}

return this.element.closest( "form, :jqmData(role='page'), :jqmData(role='dialog')" )
.find( "input[name='" + this.element[ 0 ].name + "'][type='" + this.inputtype + "']" );
return this.element
.closest( "form, :jqmData(role='page'), :jqmData(role='dialog')" )
.find( "input[name='" + this.element[ 0 ].name + "']" +
"[type='" + this.inputtype + "']" )
.add( this.element );
},

_updateAll: function() {
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/checkboxradio/checkboxradio_core.js
Expand Up @@ -189,4 +189,17 @@
deepEqual( v.prev().hasClass( "ui-checkbox-on" ), false, "Vertical: After unchecking and refreshing, the label does not have the ui-checkbox-on class" );
deepEqual( v.prev().hasClass( "ui-checkbox-off" ), true, "Vertical: After unchecking and refreshing, the label has the ui-checkbox-off class" );
});

test( "Unnamed radio", function() {
var radio = $( "#unnamed-radio" ),
label = radio.siblings( "label" );

label.click();
deepEqual( radio.prop( "checked" ), true,
"Clicking unnamed radio label checks it" );
deepEqual( label.hasClass( "ui-radio-on" ), true,
"After click, label has checked class" );
deepEqual( label.hasClass( "ui-radio-off" ), false,
"After click, label does not have unchecked class" );
});
})(jQuery);
2 changes: 2 additions & 0 deletions tests/unit/checkboxradio/index.html
Expand Up @@ -88,6 +88,8 @@
</div>
</div>

<label><input id="unnamed-radio" type="radio"></input>Unnamed radio</label>

<div data-role="fieldcontain" id="radio-active-btn-test">
<fieldset data-role="controlgroup">
<legend>Choose a pet:</legend>
Expand Down

0 comments on commit 834d5f5

Please sign in to comment.