javascriptjscriptjscolor

jscolor onchange callback does not get triggered


I'm currently developing a simple webpage that will be used to control a couple of RGB LED-Strips. To select the desired colors I want to use jscolor-color pickers as they seem quite easy to use.

The problem is, that the callback function never gets executed when a new color is selected by the user. If I use the onFineChange event, implemented in the jscolor library the callback fires as intended, but as I want to execute a function only when the mouse is released I want to use the onchange event. With the following code the onchange callback never gets executed.

I hope someone can help me out. Cheers guys!

<html>
<input class="jscolor {valueElement:null}" onchange="getColor(this)" style="border:none" id="color1">
</html>

<script>
function getColor(picker){
          console.log("Callback");
}    
</script>

Solution

  • Browsers use the callback function when you left the element focus, if you want to get the real change progress you can use the onkeyup/down event.

    Edit: if you use this js lib http://jscolor.com/examples/ then your code should work when you delete "{valueElement:null}"