Is that possible to set the active color in jPicker programatically?
-
04-10-2019 - |
Question
I'm using jPicker, and I would like to change the active color in my code (I create one instance of jPicker at the beginning, with some default active color).
Is that possible ?
Also, is that possible to make the jPicker window drag-able ? Sometimes, I would like to move the window to other location...
Solution
Yes you can set the color after it's initialized like this:
$.jPicker.List[0].color.active.val('rgb', { r: 123, g: 123, b: 123 });
//or hex style:
$.jPicker.List[0].color.active.val('ahex', 'FFFFFFFF'); //last 2 are alpha
Where each value is the 0-255 of the color for red, green, and blue. The dragging there's no built-in support for, but you may be able to use a jQuery UI .draggable()
on the panel...not sure what possible conflicts the picker's bindings will have with that.
OTHER TIPS
As you can see on the page you linked to, you can change the color by adding a color
argument.
$('#colorpicker').jPicker({
color: {active: '#FFCC00'}
});