Open GoogleCodeExporter opened 9 years ago
I can verify a portion of this defect. I built a test page with a check box
that has an ID of "ssl". If I check the box and call ;cookify() on it, I see
the cookie get set. I refresh the page and when it loads the box is not
checked (expected). I run .cookieFill() on the check box and it gets checked
(expected).
Up to that point all is well.
Then delete the cookie via $.cookies.del( 'ssl' ). I verify it is gone and
then call .cookieFill() ont ehc heck box again. The checkbox is not removed.
Does this match what you're seeing?
Thanks very much,
Jim
Original comment by auldrid...@gmail.com
on 9 Feb 2011 at 4:34
Almost it matches. I even couldn't get checkbox checked after page loaded then
called .cookieFill().
I tested again, my checkbox has a default value "true". <input id="ssl"
type="checkbox" value="true">
This is the reason. Everything goes well after I removed the default value.
But We need to set ssl checked as default value before we record user's
preference.
Original comment by exceed...@gmail.com
on 10 Feb 2011 at 1:13
I was having this same issue.
Tracked it down to Line 342 in the "cookify" function.
I changed:
if( $this.is( ':checkbox, :radio' ) )
{
if( $this.attr( 'checked' ) )
{
value = $this.val();
}
}
to:
if( $this.is( ':checkbox, :radio' ) )
{
value = $this.attr( 'checked' ) ? 'on' : 'off';
}
and now the "cookify" function stores the actual value of the checked attribute.
Prior to this, the cookie value would be set to "on", or the cookie would be
expired in .set because the value would be set to null.
By storing the value of the checked attribute even when it's off/false,
cookieFill is now able to restore the value (otherwise the default value takes
precedence)
I hope this helps someone.
Finally, kudos to James Auldridge for doing the legwork on this library.
I love the entire concept of a jQ cookieBind.
Pete
Original comment by pete....@gmail.com
on 10 Jun 2011 at 5:40
Thank for your post.
But I needed to do another change in around line 400:
change if( $this.val() === value )
to f( value === 'on' )
HTH.
Original comment by seb.ha...@gmail.com
on 22 Dec 2011 at 10:13
Original issue reported on code.google.com by
exceed...@gmail.com
on 9 Feb 2011 at 4:01