From 4ca2fc5287f731f84c9cda7e2503bcadffe6cc71 Mon Sep 17 00:00:00 2001 From: Shana Golden Date: Wed, 25 May 2011 15:45:41 -0400 Subject: [PATCH 1/2] Allow checkboxes and radio buttons to be selected with the keyboard --- js/jquery.mobile.forms.checkboxradio.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 61c2385a..70834f8f 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -58,8 +58,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { } self._cacheVals(); - - input.attr( "checked", inputtype === "radio" && true || !input.is( ":checked" ) ); + + input.attr( "checked", inputtype === "radio" && true || !(input.attr("checked")) ); // input set for common radio buttons will contain all the radio // buttons, but will not for checkboxes. clearing the checked status @@ -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).attr( "checked", true); + self._getInputSet().not($(this)).removeAttr('checked'); + } else { + $(this).removeAttr("checked"); + } self._updateAll(); }, From c9d97ef2614e18556275c3c4f94b93db1a47186a Mon Sep 17 00:00:00 2001 From: Shana Golden Date: Fri, 27 May 2011 09:50:54 -0400 Subject: [PATCH 2/2] Allow checkboxes/radio buttons to be selected with keyboard - updated to use prop() --- js/jquery.mobile.forms.checkboxradio.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 70834f8f..1dacb908 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -59,12 +59,12 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { self._cacheVals(); - input.attr( "checked", inputtype === "radio" && true || !(input.attr("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; @@ -81,10 +81,10 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { vclick: function(){ // adds checked attribute to checked input when keyboard is used if ($(this).is(":checked")) { - $(this).attr( "checked", true); - self._getInputSet().not($(this)).removeAttr('checked'); + $(this).prop( "checked", true); + self._getInputSet().not($(this)).prop('checked', false); } else { - $(this).removeAttr("checked"); + $(this).prop("checked", false); } self._updateAll(); }, @@ -132,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 );