PitPik / colorPicker

Advanced javaScript color picker and color conversion / calculation (rgb, hsv, hsl, hex, cmyk, cmy, XYZ, Lab, alpha, WCAG 2.0, ...)
http://www.dematte.at/colorPicker/
MIT License
570 stars 136 forks source link

Setting Memory Colours programatically #42

Open wizlonuk opened 8 years ago

wizlonuk commented 8 years ago

Hi

First of all, thanks for the amazing colour picker, it's got all the features I need (and more) which can't be said for others. But I was hoping you could help me out with something.

I am initialising the plugin using JQuery as so

$('#addNewColourInput').colorPicker({ memoryColors: ff.global.memoryColors, actionCallback: actionCallback )};

which works fine, but I am trying to add new memory colours after a selection has been made. I was hoping to keep my own list of colours and then just reset the memory colours object when I need to, however, I'm haping trouble doing this. Could you supply a snippet showing how I can set the memoryColours? If this isn't possible then how else could I achieve this?

Thank you for your time.

PitPik commented 8 years ago

Hi @wizlonuk, I'm not quite sure what you need to do...

Best to do so is inside the actionCallback because it's the first time you have a hold on the instance of your colorPicker (this._instance):

actionCallback: function(event, type) {
    if (type === 'init') { // the first time you created an instance
        if (document.cookie.indexOf('colorPickerMemos') !== -1) {
            this._instance.renderMemory(ff.global.memoryColors);
        }
    }
}

I hope this helps you with what you need to do ;o)