From 377c0067a7d1103821be4899b02f21b132f1fbcc Mon Sep 17 00:00:00 2001 From: John Bender Date: Mon, 2 May 2011 00:53:51 -0700 Subject: [PATCH] remove checked state from radio button inputs that are not checked. use jquery attr accessor instead of expando to guarantee consistent values. Fixes #1532. --- js/jquery.mobile.forms.checkboxradio.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index e43df296..07534379 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -58,7 +58,14 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { } self._cacheVals(); + input.attr( "checked", inputtype === "radio" && true || !input.is( ":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._updateAll(); return false; } @@ -116,7 +123,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { label = this.label, icon = label.find( ".ui-icon" ); - if ( input[0].checked ) { + // input[0].checked expando doesn't always report the proper value + // for checked='checked' + if ( $(input[0]).attr('checked') ) { label.addClass( $.mobile.activeBtnClass ); icon.addClass( this.checkedicon ).removeClass( this.uncheckedicon );