javascript - Update new color in Color Picker Palette -
i installed jquery plugin color picker: colpick.js , don't know how set new color circle icon in color palette (after refresh page element's bg changed circle icon in palette still in default color area color:'003a7d
.it not updating.)(however,color picker , cookie working well.)
this code: html :
<div id="picker"></div>
js :
if($.cookie('body_color')) { $('body,.livebgchanger ul li a').css('background-color', $.cookie('body_color')); } else { $('body,.livebgchanger ul li a').css('background-color', '#003a7d'); } $('#picker').colpick({ flat:true, submit:0, layout:'full', color:'003a7d', //default color onchange:function(hsb,hex,rgb,el){ $('body,.livebgchanger ul li a').css('background-color', '#' + hex); $.cookie('body_color', '#' + hex, { expires: 365 }); } });
before (i choose new color , "body" background-color has changed) : click view image
after refresh page: (body background color has changed circle icon , color in palette in default color area) enter link description here
how can add option , set new color circle icon in palette ?
sorry english. thanks
you're hardcoding default value color picker. should pull cookie value variable , use set background , color picker colors.
var currcolor = $.cookie('body_color') || '#003a7d'; $('body,.livebgchanger ul li a').css('background-color', currcolor); $('#picker').colpick({ flat: true, submit: 0, layout: 'full', color: currcolor.substring(1), //skip # onchange: function(hsb, hex, rgb, el) { $('body,.livebgchanger ul li a').css('background-color', '#' + hex); $.cookie('body_color', '#' + hex, { expires: 365 }); } });
Comments
Post a Comment