Knockout JS Color Picker Binding Handler

Jquery color picker bootstrap design binding handler in Knockout JS


ko.bindingHandlers.changeColor = {
    init : function(element, valueAccessor){ 
        var value = valueAccessor();
  var myColor = value;
        
        $(element).spectrum({
            beforeShow: function(color){
                $(this).spectrum("set", $(this).css("background-color"));
            },
       
            move: function(color){
              myColor(color.toHexString().toUpperCase()); 
            }
        });
   }
};

function ColorViewModel(){
    color1 = ko.observable("#FFF000");
    color2 = ko.observable("#000FFF");
}

ko.applyBindings(new ColorViewModel());
Knockout JS Color Picker Binding Handler Knockout JS Color Picker Binding Handler Reviewed by Bhaumik Patel on 7:38 PM Rating: 5