Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1709 from shanag/checkboxradio-keyboard-fix

Allow checkboxes and radio buttons to be selected with the keyboard
  • Loading branch information...
commit 4b40896b6a296b4e905b9bed05d9ebb0fdd2602a 2 parents 6fdb90d + c9d97ef
Scott Jehl authored
Showing with 11 additions and 4 deletions.
  1. +11 −4 js/jquery.mobile.forms.checkboxradio.js
View
15 js/jquery.mobile.forms.checkboxradio.js
@@ -58,13 +58,13 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
}
self._cacheVals();
-
- input.attr( "checked", inputtype === "radio" && true || !input.is( ":checked" ) );
+
+ input.prop( "checked", inputtype === "radio" && true || !(input.prop("checked")) );
// input set for common radio buttons will contain all the radio
// buttons, but will not for checkboxes. clearing the checked status
// of other radios ensures the active button state is applied properly
- self._getInputSet().not(input).removeAttr('checked');
+ self._getInputSet().not(input).prop('checked', false);
self._updateAll();
return false;
@@ -79,6 +79,13 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
},
vclick: function(){
+ // adds checked attribute to checked input when keyboard is used
+ if ($(this).is(":checked")) {
+ $(this).prop( "checked", true);
+ self._getInputSet().not($(this)).prop('checked', false);
+ } else {
+ $(this).prop("checked", false);
+ }
self._updateAll();
},
@@ -125,7 +132,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
// input[0].checked expando doesn't always report the proper value
// for checked='checked'
- if ( $(input[0]).attr('checked') ) {
+ if ( $(input[0]).prop('checked') ) {
label.addClass( $.mobile.activeBtnClass );
icon.addClass( this.checkedicon ).removeClass( this.uncheckedicon );
Please sign in to comment.
Something went wrong with that request. Please try again.