Skip to content

Commit 4ca2fc5

Browse files
author
Shana Golden
committed
Allow checkboxes and radio buttons to be selected with the keyboard
1 parent a4ee2d5 commit 4ca2fc5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

js/jquery.mobile.forms.checkboxradio.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
5858
}
5959

6060
self._cacheVals();
61-
62-
input.attr( "checked", inputtype === "radio" && true || !input.is( ":checked" ) );
61+
62+
input.attr( "checked", inputtype === "radio" && true || !(input.attr("checked")) );
6363

6464
// input set for common radio buttons will contain all the radio
6565
// buttons, but will not for checkboxes. clearing the checked status
@@ -79,6 +79,13 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
7979
},
8080

8181
vclick: function(){
82+
// adds checked attribute to checked input when keyboard is used
83+
if ($(this).is(":checked")) {
84+
$(this).attr( "checked", true);
85+
self._getInputSet().not($(this)).removeAttr('checked');
86+
} else {
87+
$(this).removeAttr("checked");
88+
}
8289
self._updateAll();
8390
},
8491

0 commit comments

Comments
 (0)