In this post I use a wonderful color picker by @lakek.
HTML:
<input type="text" data-bind="colorPicker:color" />
Javascript:
ko.bindingHandlers.colorPicker = { init: function(element, valueAccessor) { var value = valueAccessor(); $(element).val(ko.utils.unwrapObservable(value)); $(element).colorPicker(); $(element).change(function() { value(this.value); }); }, update: function(element, valueAccessor) { $(element).val(ko.utils.unwrapObservable(valueAccessor())); } }
Reference: KnockoutJs custom binding
Enjoy!
Very nice, I just used your binding code as the basis for a binding using the spectrum colour picker instead of the one you used. http://bgrins.github.io/spectrum/
The only thing i changed was the call from `$(element).colorPicker();` to `$(element).spectrum();`
Thank you internet for providing the exact answer to the question I did not even know how to ask!
I offer my humble click-throughs to appease you, in the hope that you may favour me with further precise responses to obscure coding problems in the future.
All hail!
@gavjackson – how did you know? Amazing 🙂