Search code examples
jquerycolor-picker

Is that possible to set the active color in jPicker programatically?


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.