gigebyte / cookies

Automatically exported from code.google.com/p/cookies
0 stars 0 forks source link

Please add support for check boxes #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Comment on documentation page offers patch for checkbox support.  sould be 
looked into 
anyway.

{{{
Index: jquery.cookies.2.1.0.js
===========================================================
========
--- jquery.cookies.2.1.0.js     (revision 56)
+++ jquery.cookies.2.1.0.js     (working copy)
@@ -321,16 +321,18 @@
                                                                {
                                                                        inputType = inputType.toLowerCase();
                                                                }
-                                                               if( inputType 
!== 'radio' && inputType !== 'checkbox' )
+                                                               resolvedValue = 
true;
+                                                               if( inputType 
=== 'radio' || inputType === 'checkbox' )
                                                                {
+                                                                   value = $( 
this ).attr("checked");
+                                                               } else {
                                                                        value = $( this ).val();
-                                                                       
resolvedValue = true;
                                                                }
                                                        }

                                                        if( resolvedValue )
                                                        {
-                                                               if( typeof 
value !== 'string' || value === '' )
+                                                               if( value === 
'' || value === false)
                                                                {
                                                                        value = null;
                                                                }
@@ -372,7 +374,13 @@
                                                                nodeName = this.nodeName.toLowerCase();
                                                                if( nodeName === 'input' || nodeName === 'textarea' || 
nodeName === 'select' )
                                                                {
-                                                                   $( this 
).val( value );
+                                                                   inputType = 
$( this ).attr( 'type' );
+
+                                                                   if ( 
inputType === 'checkbox' || inputType === 'radio' ) {
+                                                                       $( this 
).attr({checked: true});
+                                                                   } else {
+                                                                       $( this 
).val( value );
+                                                                   }
                                                                }
                                                                else
                                                                {
}}}

Original issue reported on code.google.com by auldrid...@gmail.com on 29 Jul 2009 at 5:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Added in r42 by cleaning up jQ usage and applying is() function

Original comment by auldrid...@gmail.com on 31 Dec 2009 at 2:46