Jquery Cookie: How Can I Save The Color Selection Of The User For The Next Visit?
I'm working on a jQuery predefined color picker. I'd like to save the color selection when the user click on one of the colors of my color picker: http://prntscr.com/7rnafa . To in
Solution 1:
See the plugin:
https://github.com/js-cookie/js-cookie
To save a cookie using the Javascript library js.cookie you would use:
Cookies.set("color", customColor);
Also to get the value from the saved cookies would be:
var customColor = Cookies.get("color");
If you ever wanted to remove that cookie you would use:
Cookies.remove("color");
Solution 2:
Use the cookie library to store the previous selection, and populate the DOM using $( document ).ready(function(){}.
If your cookie is not saving, confirm the domain which the cookie is set. Often the cookie domain will not match your site when setting a cookie. Note that cookies will not save if you are using http://localhost. Use "Resources" tab within Chrome Dev tools to confirm your cookie is set.
p.s. If you want someone to do your work for you, consider freelancer.com or odesk.
Post a Comment for "Jquery Cookie: How Can I Save The Color Selection Of The User For The Next Visit?"