spectrum
spectrum copied to clipboard
Color preview should default to placeholder value
It would be nice if the preview color shown per default (currently black/empty) would default to the value set as placeholder of the input field (if set).
Example:
<input id='colorpicker' placeholder="#123456"/>
Should display the color preview next to the input colored with #123456 if the field itself is empty.
I achieved this by putting the following before initializing spectrum on the field (in my case I was doing an .each() iteration over a number of inputs so $(this) was available):
if(!$(this).val()) $(this).val($(this).attr('placeholder'));
Similar should be able to be accomplished without setting the input value by using the color
spectrum initialization option:
color:$(this).val()?$(this).val():$(this).attr('placeholder')