Custom Color Component

I think the problem is your this argument

<input type = 'color' id = "choosecolor" onchange="color_changed_event(this)">

<script>
function color_changed_event(color_input) {
  anvil.call(color_input, "my_change_func", "color changed")
}
</script>

If you ever want to move into the anvil.js interop world:

In html:

<input type='color'>

In python:

import anvil.js

class colorpicker(colorpickerTemplate):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)
    dom_node = anvil.js.get_dom_node(self)
    self.color_node = dom_node.querySelector("input")
    self.color_node.onchange = self.color_changed

  def color_changed(self, js_event):
    self.raise_event("x-color_changed", color=self.color_node.value)
1 Like