Skip to content

Button: Newly added radios need to become UI buttons in refresh. Fixed #... #888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/unit/button/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ <h2 id="qunit-userAgent"></h2>
<input type="radio" id="radio02" name="radio"><label for="radio02">Choice 2</label>
<input type="radio" id="radio03" name="radio"><label for="radio03">Choice 3</label>
</div>
<div id="checkbox0">
<input type="checkbox" id="checkbox01" name="checkbox"><label for="checkbox01">Choice 1</label>
<input type="checkbox" id="checkbox02" name="checkbox"><label for="checkbox02">Choice 2</label>
<input type="checkbox" id="checkbox03" name="checkbox"><label for="checkbox03">Choice 3</label>
</div>
<form>
<div id="radio1" style="margin-top: 2em;">
<input type="radio" id="radio11" name="radio"><label for="radio11">Choice 1</label>
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/button/button_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,26 @@ test( "refresh: Ensure disabled state is preserved correctly.", function() {
ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh.");
});

// See #8975
test("refresh: buttonset should turn added elements into button widgets.", function() {
expect( 2 );
var radioButtonset = $("#radio0").buttonset(),
checkboxButtonset = $("#checkbox0").buttonset();

radioButtonset.append(
'<input type="radio" name="radio" id="radio04">' +
'<label for="radio04"></label>'
);
checkboxButtonset.append(
'<input type="checkbox" name="checkbox" id="checkbox04">' +
'<label for="checkbox04"></label>'
);

radioButtonset.buttonset("refresh");
checkboxButtonset.buttonset("refresh");

equal( radioButtonset.find(":ui-button").length, 4 );
equal( checkboxButtonset.find(":ui-button").length, 4 );
});

})(jQuery);
6 changes: 4 additions & 2 deletions ui/jquery.ui.button.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,13 @@ $.widget( "ui.button", {
if ( this.type === "radio" ) {
radioGroup( this.element[0] ).each(function() {
if ( $( this ).is( ":checked" ) ) {
$( this ).button( "widget" )
$( this ).button()
.button( "widget" )
.addClass( "ui-state-active" )
.attr( "aria-pressed", "true" );
} else {
$( this ).button( "widget" )
$( this ).button()
.button( "widget" )
.removeClass( "ui-state-active" )
.attr( "aria-pressed", "false" );
}
Expand Down