Hope this is the right place for my question. I'm trying to update a text input. Having entered something in "input_1", I'd like to update the text that's shown in "input_2". With the code shown below, I'd expect "Auto text" to appear in input_2's text field. But that does not happen.
include karax / prelude
type
  Model = object
    value_1: string
    value_2: string
var model: Model
proc setInput(ev: Event, node:VNode): auto =
  model.value_1 = $node.text
  model.value_2 = "Auto text"
proc createDom(): VNode =
  result = buildHtml(tdiv):
    input(id = "input_1", onchange=setInput)
    input(id = "input_2", value = model.value_2)
    input(id = "input_3", value = "Initial Value")
    p: text $model
setRenderer createDom
 I'd appreciate any kind of hint for solving my problem. Thanks a lot.To answer my own question. The following code does the trick:
include karax / prelude
from dom import getElementById, setAttribute
type
  Model = object
    value_1: string
    value_2: string
var model: Model
proc setInput(ev: Event, node:VNode): auto =
  model.value_1 = $node.text
  model.value_2 = "Auto Text"
  let el = dom.document.getElementById("input_2")
  el.setAttribute("value", model.value_2)
proc createDom(): VNode =
  result = buildHtml(tdiv):
    input(id = "input_1", onchange=setInput)
    input(id = "input_2")
    input(id = "input_3", value = "Initial Value")
    p: text $model
setRenderer createDom
That's a hack. You shouldn't be modifying DOM nodes from underneath Karax.
That said, I can't blame you because I ran into this too. The way Karax handles this isn't ideal and I created an issue for this: https://github.com/pragmagic/karax/issues/61.
TL;DR: Use setInputText.