Skip to content

Instantly share code, notes, and snippets.

@dinhhuydh
Last active August 14, 2023 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinhhuydh/c6f27c05c2f47e86d3ce1474cb1b8076 to your computer and use it in GitHub Desktop.
Save dinhhuydh/c6f27c05c2f47e86d3ce1474cb1b8076 to your computer and use it in GitHub Desktop.
Add more information for Events.onInput in elm
{-| Suppose that you have many inputs for list of users (first_name, last_name)
To handle event onInput for inputs for each elements, it needs to bind Event.onInput for
inputs but Event.onInput support pass one string value. To customize that it's able to
include more information, for example user id, we can declare the Message as below:
-}
type Msg
= UpdateFirstName Int String
-- View
Html.input [Events.onInput (UpdateFirstName user.id) ] []
-- Reference: https://package.elm-lang.org/packages/elm/html/latest/Html-Events#onInput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment