Spectrum Color Picker Change event
I'm trying to use the spectrum color picker 2.
When I load the page I can click anywhere on the page outside the color picker and the color picker's change event fires. What's more it throws an error when I try to use color.toHexString() because the color is null.
This happens even if I haven't clicked the color picker at all.
I have the option: clickoutFiresChange set to false.
If I can't fix this I can't use this color picker.
How can I make it stop firing the change event every time I click anywhere on the page?
- $(clrpkrAcntClr).spectrum({
type: "flat",
flat: true,
showInput: true,
preferredFormat: "hex",
showPalette: false,
allowEmpty: true,
showAlpha: false,
clickoutFiresChange: false,
change: function(color) {
var prmColor;
try {
prmColor = color.toHexString(); // #ff0000
}
catch(err) {
console.log(err);
return false;
}
frmEmailTmpl.accentColor.value = prmColor;
console.log("Color: " + frmEmailTmpl.accentColor.value);
}
});