Skip to content

Pretty origin strings in Kino? #2154

Answered by jonatanklosko
djacobs7 asked this question in Q&A
Discussion options

You must be logged in to vote

If you want to give the user feedback you can render a frame and update it's content once the form is submitted:

inputs = [
  target_section: Kino.Input.select("section", Enum.map([:a, :b], &{&1, &1})),
  example_section: Kino.Input.textarea("example")
]

form = Kino.Control.form(inputs, submit: "Generate")
frame = Kino.Frame.new()

Kino.Control.stream(form)
|> Kino.listen(fn event ->
  Kino.Frame.render(frame, Kino.Text.new("Submitted!"), to: event.origin)
end)

Kino.Layout.grid([form, frame])

Note that to: event.origin means that the frame is updated only for the user that submitted the form. If you want the result to persist on refresh you can skip that option :)

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jonatanklosko
Comment options

Comment options

You must be logged in to vote
1 reply
@jonatanklosko
Comment options

Answer selected by hugobarauna
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@josevalim
Comment options

@djacobs7
Comment options

@josevalim
Comment options

@djacobs7
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants