[https://github.com/bung87/nimvideo/blob/master/src/nimvideo/header.nim#L19](https://github.com/bung87/nimvideo/blob/master/src/nimvideo/header.nim#L19)
    
    
     nim
    proc render(x:VComponent):VNode =
      let self = Thead(x)
      var onSelect = proc (s: cstring) = echo "now "
      var choices = @[toJs"1111",toJs"22222"]
      var searchBox = 
buildHtml(input(type="text",class="pure-input-rounded",autocomplete="off"))
      var autoRef = autocomplete(choices,searchBox, onSelect)
      proc cb(httpStatus: int; response: cstring) =
        var data = fromJSON[seq[JsObject] ] response
        for item in data:
          choices.add item.show.name
        autoRef.markDirty()
        redraw()
        console.log "cb"
      
      proc onkeyuplater(ev: kdom.Event; n: VNode) =
        ajax(cstring"get",cstring"http://api.tvmaze.com/search/shows?"; & 
cstring"q=" & n.dom.value,cb)
      
      searchBox.addEventListener(EventKind.onkeyuplater,onkeyuplater )
    
    
    Run

Reply via email to