-
Notifications
You must be signed in to change notification settings - Fork 75
Description
I'm building an app with an eye dropper tool that needs to change the colour stored inside the colour picker, from outside the picker. Here's how I'm setting the colour at the moment (not sure if this is the right way to do it!):
var colourPicker = $("#picker_id").colorPicker();
colourPicker.colorPicker.color.setColor(tool.colourFg);
colourPicker.colorPicker.render();
This works, but only after the user has clicked the picker already. If the user hasn't clicked the picker yet, this error occurs:
Uncaught TypeError: Cannot read property '_colorMode' of undefined
This is due to an empty _$trigger variable, which seems to contain the DOM element representing the picker. What I'm looking for is a way to initialise the picker before the user clicks it so that this error does not occur.
I couldn't figure out how to set the _$trigger variable myself as it seems to be encapsulated pretty tight - not that easy to access outside of the picker module.
Here is a jsfiddle that demonstrates the problem:
https://jsfiddle.net/4phnsz7x/19/
If you click the link before clicking the picker, you get the error. If you click the picker first, there is no error.