I am hoping someone can explain to me why the inputField variable seems to always returns null. I also tried gettAttributeById but that returns blank. I'm just playing around trying to understand Karax. Thank you.
import karax / [kbase, vdom,kdom, karax, kajax, karaxdsl]
import sugar
type Message = ref object
content: kstring
var message = Message(content: "Blank")
proc updateSection() =
proc cb(stat: int, resp: cstring) =
if stat == 200:
let inputField = getVNodeById("input1").text
message.content = "Worked"
echo inputField
ajaxGet("https://httpbin.org/get", @[], cb)
proc createDom(): VNode =
result = buildHtml(tdiv):
header:
h1: text "Web App"
main:
section:
blockquote: text "Form"
section:
label(`for`="input1"): text "Entry"
input(`class` = "input", id = "input1")
button(onClick = updateSection): text "Submit"
section:
p(id="test1"): text message.content
footer: text "Footer Information"
setRenderer createDom