Created
November 14, 2013 18:50
-
-
Save EminenceHC/7472270 to your computer and use it in GitHub Desktop.
Remember checkbox state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="well"> | |
<p><input type="checkbox" name="basic" class="box" /> Basic</p> | |
<p><input type="checkbox" name="address" class="box" /> Address</p> | |
<p><input type="checkbox" name="phone" class="box" /> Phone</p> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('ready page:load', function(){ | |
$("input.box").each(function() { | |
var mycookie = $.cookie($(this).attr('name')); | |
if (mycookie && mycookie == "true") { | |
$(this).prop('checked', mycookie); | |
} | |
}); | |
$("input.box").change(function() { | |
$.cookie($(this).attr("name"), $(this).prop('checked'), { | |
path: '/', | |
expires: 365 | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment