Side navigation
Ticket #3609: jqueryjs-set-radio-single-val.diff
File jqueryjs-set-radio-single-val.diff, 0.8 KB (added by jhohm, November 14, 2008 05:46PM UTC)
Patch to provide expected behavior for setting value of radio buttons or checkboxes
Index: jquery/src/core.js
===================================================================
--- jquery/src/core.js (revision 5945)
+++ jquery/src/core.js (working copy)
@@ -407,9 +407,13 @@
if ( this.nodeType != 1 )
return;
- if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
- this.checked = (jQuery.inArray(this.value, value) >= 0 ||
- jQuery.inArray(this.name, value) >= 0);
+ if ( /radio|checkbox/.test( this.type ) ) {
+ if ( jQuery.isArray(value) )
+ this.checked = (jQuery.inArray(this.value, value) >= 0 ||
+ jQuery.inArray(this.name, value) >= 0);
+ else
+ this.checked = (this.value == value || this.name == value);
+ }
else if ( jQuery.nodeName( this, "select" ) ) {
var values = jQuery.makeArray(value);
Download in other formats:
Original Format
File jqueryjs-set-radio-single-val.diff, 0.8 KB (added by jhohm, November 14, 2008 05:46PM UTC)
Patch to provide expected behavior for setting value of radio buttons or checkboxes
Index: jquery/src/core.js
===================================================================
--- jquery/src/core.js (revision 5945)
+++ jquery/src/core.js (working copy)
@@ -407,9 +407,13 @@
if ( this.nodeType != 1 )
return;
- if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
- this.checked = (jQuery.inArray(this.value, value) >= 0 ||
- jQuery.inArray(this.name, value) >= 0);
+ if ( /radio|checkbox/.test( this.type ) ) {
+ if ( jQuery.isArray(value) )
+ this.checked = (jQuery.inArray(this.value, value) >= 0 ||
+ jQuery.inArray(this.name, value) >= 0);
+ else
+ this.checked = (this.value == value || this.name == value);
+ }
else if ( jQuery.nodeName( this, "select" ) ) {
var values = jQuery.makeArray(value);